Is there a bash command to find the IP address for an Ubuntu box? I need to find the IP address so I can ssh into the machine later.
|
|
|
|||
|
|
If you have an internal address in use, checking
might be a good idea on unix shells. If you get a different answer from the " Even if all seems fine, you could have a firewall in place that will disallow incoming ssh connections.
That will confirm connectivity through,
|
|||||||||
|
If you need your internal adress append your interface after ifconfig, e.g.
|
||||
|
If you are behind a NAT, and need the public IP, use this: wget -q -O - checkip.dyndns.org|sed -e 's/.Current IP Address: //' -e 's/<.$//' taken from: http://www.go2linux.org/what-is-my-public-ip-address-with-linux |
|||
|
|
|
|
|||
|
|
|
If you need to find out what the IP address of your router, you could run this command. dig +short myip.opendns.com @208.67.222.222 @208.67.220.220 If you are using OpenDNS for your dns server, you could shorten it to: dig +short myip.opendns.com You could also use this command. curl http://myip.dnsomatic.com |
|||
|
|
|
The simplest way to go about it is probably
assuming the machine has a single IP address on the default wired interface - you might need
if it's on WiFi. |
|||
|
|
It will show you the IP address of living - has link - interfaces. But it is not a bash command. Bash has no ability to know about IP and network at all. |
|||
|
|
|
What I understand is you want to connect a remote ubuntu machine which has dynamic ip. Go dyndns.org site and open a free account. Then on the remote machine you need to install a dynamic ip tool.
so you can ssh remote machine via
So after configuration you will never need the remote machine ip address. |
|||
|
|
If you have multiple interfaces, could be useful to specify which one you want IP. if you want IPV4 address of interface 'eth0':
if you want IPV6 address of interface 'eth0':
if you want to search for an IP between two common interfaces of a laptop, wlan0 and eth0:
|
||||
|
|
|
I once golfed the extraction of IP address on Linux: http://www.catonmat.net/blog/golfing-the-extraction-of-ip-addresses-from-ifconfig/ |
|||
|
|