Wednesday, December 12, 2012

How to find IP addresses and use them in Linux

One of the reasons why one should track their IP address is perhaps dynamic DNS. It might be easier to get a generic dynamic DNS name associated with your IP so you can run your FTP SSH http server without having to worry about your IP changing all the time. With a bit of scripting or with a router that supports Dynamic DNS and doesn't forget to update it whenever the ADSL/Cable modem
loses its settings (like mine does) Dynamic DNS can work miracles.

There are lots of sites that can get your IP and spit it back...www.whatismyip.com
isn't the cleanest one of all ... try checkip.dyndns.org with the following
command:

curl -X GET http://checkip.dyndns.org

You'll get the following:
Current IP Address: x.x.x.x (Where x represents each number of your
external Ip address. All this is wrapped in http and body tags but the tags will dissapear once I paste them here)

For local IP addresses check this out:

ip -f inet addr

will give you the local IP addresses for your nic and localhost in the following format:

1: lo: mtu 16436 qdisc noqueue state UNKNOWN 
inet 127.0.0.1/8 scope host lo
2: eth0: mtu 1500 qdisc cbq state UP qlen 1000
inet 192.168.0.10/24 brd 192.168.0.255 scope global eth0 

then there's the old standby: ifconfig eth0 

But for some distributions this requires higher privileges (ie root)

Also look at your distribution's repositories for a Dynamic DNS client that can update your Dynamic DNS Settings every time they detect a change in the external IP address

No comments:

Post a Comment