Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 219
  • Last Modified:

Setting current IP address in configuration file

Hi

As a relative newbie to Linux I need some advice.

My computer gets a dynamically IP address when starting up (from my provider, using DHCP). Now I need to specify this IP address in a configuration file used by one of my server daemons.

The line in question in my config file reads:
client_ip = "123.123.123.123"

Is there an easy way to change this line so it contains my dynamically assigned IP? Specifying a DNS name is not possible, I really need to use the numerical IP.

Can anybody help me?

Thank You!
rjud
0
rjud
Asked:
rjud
1 Solution
 
majorwooCommented:
just set
EXTIF="eth0" or "ppp0" or whatever your external interface is

client_ip="`/sbin/ifconfig $EXTIF | grep 'inet addr' | awk '{print $2}' | sed -e 's/.*://'`"

should do it for you
0
 
rjudAuthor Commented:
This works great (and it looks pretty cool too).

Thanks a lot!
rjud
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now