Ubuntu: How do I find my network IP address, netmask, and gateway info?
Channel: Roel Van de Paar
Date: 18/06/2019

Ubuntu: How do I find my network IP address, netmask, and gateway info?


Question: I'm trying to make my IP address static as I hear it fixes slow browsing
issues.
When I click on connection information under the networking menu of the gray
taskbar, it tells me about the IP address, subnet mask, and DNS, but nothing
about the gateway.
I would like to know if there's a terminal command to find the information.

Solutions Sample (Please watch the whole video to see all solutions, in order of how many people found them helpful):

== This solution helped 24 people ==
You can use ifconfig, it will show your inet address (IP) and mask.
For the gateway, issue the ip route command and take note of the default route.
[ifconfigandiproute]
Hope this can help you.

== This solution helped 37 people ==
I have this command as an alias for "ipconfig" (up to 14.04):
nmcli dev list iface eth0 | grep IP4
An example listing is:
IP4-SETTINGS.ADDRESS: 192.168.1.110
IP4-SETTINGS.PREFIX: 24 (255.255.255.0)
IP4-SETTINGS.GATEWAY: 192.168.1.1
IP4-DNS1.DNS: 208.67.222.222
IP4-DNS2.DNS: 208.67.220.220
If eth0 doesn't work, you may need to use eth1, eth2, ... depending on your
configuration.
EDIT: 2/8/16
Note that this only works in versions before v15.04 (or possibly before v14.10;
I have v14.04). For newer versions, you can use this:
 nmcli dev show eth0

== This solution helped 3 people ==
nm-tool will also do the job.
$ nm-tool
NetworkManager Tool

State: connected (global)

....

IPv4 Settings:
Address: 192.168.1.110
Prefix: 24 (255.255.255.0)
Gateway: 192.168.1.1

DNS: 208.67.222.222
DNS: 208.67.220.220

== This solution helped 5 people ==
http://www.zytrax.com/tech/protocols/ip-classes.html explains how the network
and broadcast addresses can be calculated via a netmask and a computer's ip
address. To simplify that article: network is the lowest possible address in
the range of ip addresses left over from the netmask. broadcast is the highest
numbered ip address in that range. The "range of ip addresses left over from
the netmask" is known as the local network.
"The network" typically means everyone above you, including the Internet. To
get to "the network", the network address is used. In reality, most people call
"the network" anything with ethernet cables that can talk to each other.
Example: your ISP gives you info to type into a wireless router: a static IP
address of 99.1.81.209 and your netmask is 255.255.255.224. Now you're wanting
to set up an ubuntu firewall and need to set up your public interface:
Calculate network IP address:
255.255.255.224 -＞ last octet = E0
99. 1. 81.209 -＞ last octet = D1
Logical AND the mask and your ip:
E0 & D1 = C0 = 192
--＞ network = 99.1.81.192

Calculate broadcast address:
255.255.255.224 : E0 -＞ there are 1F = 31,
-＞ broadcast = 99.1.81.192 + .31 = 99.1.81.223
The other way...
Calculate broadcast address:
255.255.255.224 -＞ last octet = E0
99. 1. 81.209 -＞ last octet = D1
Hosts' IPs = 1F
Logical OR the hosts ips with your ip:
1F | D6 = DF = 223
--＞ broadcast = 99.1.81.223
Often, you'll see networks described with a /. Here's this network:
255.255.255.224 is the netmask, add up the "1" bits:
8 + 8 + 8 + 3 = 27
so "this network" gets /27 notation
and can be described as 99.1.81.192/27

With thanks & praise to God! With thanks to all the many who have made this project possible! | Content (except music & images) licensed under cc by-sa 3.0 | Music & music license: https://www.bensound.com/royalty-free-music | Images & images license: https://stocksnap.io/license and others | With thanks to user Sisir (https://askubuntu.com/users/54055), user Sergiy Kolodyazhnyy (https://askubuntu.com/users/295286), user Peter Mortensen (https://askubuntu.com/users/10883), user Osni Araújo (https://askubuntu.com/users/95277), user Marty Fried (https://askubuntu.com/users/39753), user jeff (https://askubuntu.com/users/95268), user Elder Geek (https://askubuntu.com/users/225694), user Chris K (https://askubuntu.com/users/68389), user 7hi4g0 (https://askubuntu.com/users/222777), and the Stack Exchange Network (http://askubuntu.com/questions/197628). Trademarks are property of their respective owners. Disclaimer: All information is provided "AS IS" without warranty of any kind. You are responsible for your own actions. Please contact me if anything should be amiss at Roel D.OT VandePaar A.T gmail.com.