Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 21 down vote accepted

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.PREFIX:                    24 (

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
share|improve this answer
Because my subnet mask was in DHCP4.*, I needed nmcli dev list iface eth0 | grep -e IP4 -e subnet_mask – klaus se Jul 8 '14 at 11:05
doesn't work for me. – dlundy1 Jul 10 '15 at 18:34
not supported from OS version 15.10. – Shubh Jan 20 at 13:21
@Shubh , I know; I'll add that caveat to the answer to stop future comments about it. – Marty Fried Feb 8 at 23:46
Also make a note this will not work in cases where the system devices are controlled by /etc/network/interfaces / the kernel; for example, my laptop has a static IPv4 of with a netmask of (or /24 if you prefer CIDR prefixes), which is used in a static-LAN environment, and is configured through /etc/network/interfaces - this is listed as "unmanaged" if you have Network Manager on your system, so nmcli will never show the configurations in place there. – Thomas Ward Feb 9 at 0:07

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.


Hope this can help you.

share|improve this answer
+1 for doing this without having to install additional services – Chausser Mar 10 '15 at 1:56

This website 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 and your netmask is Now you're wanting to set up an ubuntu firewall and need to set up your public interface:

Calculate network IP address: -> last octet = E0
 99.  1. 81.209 -> last octet = D1
Logical AND the mask and your ip: 
E0 & D1 = C0 = 192
--> network =

Calculate broadcast address: : E0 -> there are 1F = 31,
-> broadcast = + .31 =

The other way...

Calculate broadcast address: -> 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 =

Often, you'll see networks described with a /. Here's this network: is the netmask, add up the "1" bits:
 8 + 8 + 8 + 3  = 27
so "this network" gets /27 notation
and can be described as
share|improve this answer

nm-tool will also do the job.

$ nm-tool
NetworkManager Tool

State: connected (global)


  IPv4 Settings:
    Prefix:          24 (

share|improve this answer

The default route is another name for gateway, and is listed there, but you don't "make" your IP static unless it is a local address assigned by your router. Normally your ISP assigns you a dynamic address, and that is what you have to use. Rather than try some random voodoo you should try asking a question about the real problem you are having and hopefully get a proper fix.

share|improve this answer

I use the following to get an overview of my network configuration:

ip addr , this show you an overview of your NIC settings route -n , it gives you a nice overview of where your traffic is going. cat /etc/resolv.conf for dns info cat /etc/hosts for preloaded hostnames

Changing to a static IP address will not affect your browsing speed though. The only difference between static and dynamic is that on static, you always have the same IP address. With dynamic, you will be assigned a "random" IP address by your DHCP server when you connect to the network. Once you have been assigned an IP address, it will behave exactly the same way as if you had assigned yourself a static IP addresss.

share|improve this answer

protected by Community Jan 14 '15 at 11:35

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.