How to get my dhcp ip address, whether i am in a local network?
I.e. if we have internet access in local network, but i want to know my dhcp server IP .. like " what is my IP" ..
How to get my dhcp ip address, whether i am in a local network?
I.e. if we have internet access in local network, but i want to know my dhcp server IP .. like " what is my IP" ..
Edit
Your question was worded in slightly confusing way. Getting your public IP form terminal can be done with curl https://diagnostic.opendns.com/myip. Open DNS has web service that tells you your IP address, which is pretty much just a web page , with only one text - your IP. Effectively, you are downloading a web page that tells you your IP.
Original
Typically dhcp server is located on the router. Thus , your main goal then is to get address of the router, which in networking terms would be default gateway. Thus , effectively your question can be solved by the multiple solutions as described in my answer here. The simplest method is to use netstat -nr command.
There is another method as well: nmcli dev list | grep -i dhcp_server_identifier (Ubuntu 14.04 and earlier). Sample output for that would be:
$ nmcli dev list | grep -i dhcp_server_identifier
DHCP4.OPTION[13]: dhcp_server_identifier = 192.168.0.1
With Ubuntu 15.04 the nmcli version is different, hence you have to enter slightly different command:
nmcli dev show | \grep 'gw ='
Side note : grep in my install of 15.04 is aliased to grep --color=auto which prints colorized output. If we want just to see the particular lines, we need to use simple grep, which the forward slash instructs the shell to use.
What is my ip shows you the public IP of your gateway. If this is what you are looking for you wan use:
nslookup myip.opendns.com