{"id":321,"date":"2018-10-17T08:13:44","date_gmt":"2018-10-17T08:13:44","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/17\/find-how-linux-get-ip-address-from-command\/"},"modified":"2018-10-17T08:13:44","modified_gmt":"2018-10-17T08:13:44","slug":"find-how-linux-get-ip-address-from-command","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/17\/find-how-linux-get-ip-address-from-command\/","title":{"rendered":"Find How Linux Get IP Address From Command"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" alt=\"Get IP Address Linux Systems\" height=\"341\" src=\"https:\/\/linoxide.com\/wp-content\/uploads\/2018\/10\/Get-IP-Address-Linux-Systems.png\" width=\"713\" \/><\/p>\n<p>How many commands you know to get IP address on your Linux systems? In this article, we&#8217;ll discuss a few ways to get IP address as well as public IP on Linux.<\/p>\n<ol>\n<li><a href=\"#1\">ifconfig command<\/a><\/li>\n<li><a href=\"#2\">ip addr<\/a><\/li>\n<li><a href=\"#3\">Hostname -I command<\/a><\/li>\n<li><a href=\"#4\">nmcli command<\/a><\/li>\n<li><a href=\"#5\">ip route <\/a><\/li>\n<li><a href=\"#6\">Graphical Method<\/a><\/li>\n<li><a href=\"#7\">Display Public IP address<\/a><\/li>\n<\/ol>\n<h2>1) ifconfig command<\/h2>\n<p>ifconfig is short for interface configuration. It&#8217;s a widely used command line tool used for configuration &amp; viewing of ip addresses, and enabling\/disabling network interfaces.<\/p>\n<p>Note: ifconfig command is deprecated, try using ip command.<\/p>\n<p>Read Also: <a href=\"https:\/\/linoxide.com\/linux-command\/use-ip-command-linux\/\" target=\"_blank\">How to use IP Command in Linux with Examples<\/a><\/p>\n<h3>ifconfig \/ ifconfig -a<\/h3>\n<p>ifconfig with no arguments will display statistics of all active interfaces. This is the same as running ifconfig -a<\/p>\n<p>Example<\/p>\n<p>ifconfig<\/p>\n<p>Output<\/p>\n<p>eth0: flags=4099&lt;UP,BROADCAST,MULTICAST&gt; mtu 1500&#xD;<br \/>\n ether a0:2b:b8:22:0c:6b txqueuelen 1000 (Ethernet)&#xD;<br \/>\n RX packets 0 bytes 0 (0.0 B)&#xD;<br \/>\n RX errors 0 dropped 0 overruns 0 frame 0&#xD;<br \/>\n TX packets 0 bytes 0 (0.0 B)&#xD;<br \/>\n TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0&#xD;<br \/>\n&#xD;<br \/>\nlo: flags=73&lt;UP,LOOPBACK,RUNNING&gt; mtu 65536&#xD;<br \/>\n inet 127.0.0.1 netmask 255.0.0.0&#xD;<br \/>\n inet6 ::1 prefixlen 128 scopeid 0x10&#xD;<br \/>\n loop txqueuelen 1000 (Local Loopback)&#xD;<br \/>\n RX packets 28212 bytes 8319418 (7.9 MiB)&#xD;<br \/>\n RX errors 0 dropped 0 overruns 0 frame 0&#xD;<br \/>\n TX packets 28212 bytes 8319418 (7.9 MiB)&#xD;<br \/>\n TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0&#xD;<br \/>\n&#xD;<br \/>\nwlan0: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt; mtu 1500&#xD;<br \/>\n inet 192.168.43.156 netmask 255.255.255.0 broadcast 192.168.43.255&#xD;<br \/>\n inet6 fe80::9ed2:1eff:fe31:3fb9 prefixlen 64 scopeid 0x20&#xD;<br \/>\n ether 9c:d2:1e:31:3f:b9 txqueuelen 1000 (Ethernet)&#xD;<br \/>\n RX packets 88974 bytes 98475476 (93.9 MiB)&#xD;<br \/>\n RX errors 0 dropped 0 overruns 0 frame 0&#xD;<br \/>\n TX packets 59034 bytes 7601548 (7.2 MiB)&#xD;<br \/>\n TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0&#xD;<\/p>\n<h3>ifconfig <\/h3>\n<p>To get an IP address of a specific network interface, run ifconfig followed by an interface name<\/p>\n<p>Example<\/p>\n<p>ifconfig eth0<\/p>\n<p>Output<\/p>\n<p>wlan0: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt; mtu 1500&#xD;<br \/>\n inet 192.168.43.156 netmask 255.255.255.0 broadcast 192.168.43.255&#xD;<br \/>\n inet6 fe80::9ed2:1eff:fe31:3fb9 prefixlen 64 scopeid 0x20&#xD;<br \/>\n ether 9c:d2:1e:31:3f:b9 txqueuelen 1000 (Ethernet)&#xD;<br \/>\n RX packets 92374 bytes 98997644 (94.4 MiB)&#xD;<br \/>\n RX errors 0 dropped 0 overruns 0 frame 0&#xD;<br \/>\n TX packets 62046 bytes 8082927 (7.7 MiB)&#xD;<br \/>\n TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0&#xD;<\/p>\n<h2>2) ip addr<\/h2>\n<p>ip addr is yet another command you can use to get an IP address of a system and other interface statistics<\/p>\n<p>Example<\/p>\n<p>ip addr<\/p>\n<p>Output<\/p>\n<p>1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000&#xD;<br \/>\n link\/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00&#xD;<br \/>\n inet 127.0.0.1\/8 scope host lo&#xD;<br \/>\n valid_lft forever preferred_lft forever&#xD;<br \/>\n inet6 ::1\/128 scope host &#xD;<br \/>\n valid_lft forever preferred_lft forever&#xD;<br \/>\n2: eth0: &lt;NO-CARRIER,BROADCAST,MULTICAST,UP&gt; mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000&#xD;<br \/>\n link\/ether a0:2b:b8:22:0c:6b brd ff:ff:ff:ff:ff:ff&#xD;<br \/>\n3: wlan0: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc mq state UP group default qlen 1000&#xD;<br \/>\n link\/ether 9c:d2:1e:31:3f:b9 brd ff:ff:ff:ff:ff:ff&#xD;<br \/>\n inet 192.168.43.156\/24 brd 192.168.43.255 scope global dynamic noprefixroute wlan0&#xD;<br \/>\n valid_lft 3489sec preferred_lft 3489sec&#xD;<br \/>\n inet6 fe80::9ed2:1eff:fe31:3fb9\/64 scope link noprefixroute &#xD;<br \/>\n valid_lft forever preferred_lft forever&#xD;<\/p>\n<h2>3) Hostname -I command<\/h2>\n<p>To get the IP address of active network connections, run<\/p>\n<p>hostname -I<\/p>\n<p>Output<\/p>\n<p>192.168.43.156<\/p>\n<h2>4) nmcli command<\/h2>\n<p>nmcli &#8211; Network Manager command Line interface &#8211; is a command line tool used for creating, editing, displaying, deleting, activating and deactivating connections.<\/p>\n<h3>nmcli<\/h3>\n<p>Example<\/p>\n<p>nmcli<\/p>\n<p>Output<\/p>\n<p>wlan0: connected to TECNO Camon CX&#xD;<br \/>\n &#8220;Realtek RTL8188EE&#8221;&#xD;<br \/>\n wifi (rtl8188ee), 9C:D2:1E:31:3F:B9, hw, mtu 1500&#xD;<br \/>\n ip4 default&#xD;<br \/>\n inet4 192.168.43.156\/24 &#xD;<br \/>\n route4 0.0.0.0\/0&#xD;<br \/>\n route4 192.168.43.0\/24&#xD;<br \/>\n inet6 fe80::9ed2:1eff:fe31:3fb9\/64&#xD;<br \/>\n route6 fe80::\/64&#xD;<br \/>\n route6 ff00::\/8&#xD;<br \/>\n&#xD;<br \/>\neth0: unavailable&#xD;<br \/>\n &#8220;Realtek RTL810xE&#8221;&#xD;<br \/>\n ethernet (r8169), A0:2B:B8:22:0C:6B, hw, mtu 1500&#xD;<br \/>\n&#xD;<br \/>\nlo: unmanaged&#xD;<br \/>\n &#8220;lo&#8221;&#xD;<br \/>\n loopback (unknown), 00:00:00:00:00:00, sw, mtu 65536&#xD;<br \/>\n&#xD;<br \/>\nDNS configuration:&#xD;<br \/>\n servers: 192.168.43.1&#xD;<br \/>\n interface: wlan0&#xD;<br \/>\n&#xD;<br \/>\nUse &#8220;nmcli device show&#8221; to get complete information about known devices and&#xD;<br \/>\n&#8220;nmcli connection show&#8221; to get an overview on active connection profiles.&#xD;<\/p>\n<h3>nmcli device show<\/h3>\n<p>To get the IP address and even more detailed statistics, run<\/p>\n<p>nmcli device show<\/p>\n<p>Output<\/p>\n<p>GENERAL.DEVICE: wlan0&#xD;<br \/>\nGENERAL.TYPE: wifi&#xD;<br \/>\nGENERAL.HWADDR: 9C:D2:1E:31:3F:B9&#xD;<br \/>\nGENERAL.MTU: 1500&#xD;<br \/>\nGENERAL.STATE: 100 (connected)&#xD;<br \/>\nGENERAL.CONNECTION: TECNO Camon CX&#xD;<br \/>\nGENERAL.CON-PATH: \/org\/freedesktop\/NetworkManager\/ActiveConnection\/1&#xD;<br \/>\nIP4.ADDRESS[1]: 192.168.43.156\/24&#xD;<br \/>\nIP4.GATEWAY: 192.168.43.1&#xD;<br \/>\nIP4.ROUTE[1]: dst = 0.0.0.0\/0, nh = 192.168.43.1, mt = 600&#xD;<br \/>\nIP4.ROUTE[2]: dst = 192.168.43.0\/24, nh = 0.0.0.0, mt = 600&#xD;<br \/>\nIP4.DNS[1]: 192.168.43.1&#xD;<br \/>\nIP6.ADDRESS[1]: fe80::9ed2:1eff:fe31:3fb9\/64&#xD;<br \/>\nIP6.GATEWAY: &#8211;&#xD;<br \/>\nIP6.ROUTE[1]: dst = fe80::\/64, nh = ::, mt = 600&#xD;<br \/>\nIP6.ROUTE[2]: dst = ff00::\/8, nh = ::, mt = 256, table=255&#xD;<br \/>\n&#xD;<br \/>\nGENERAL.DEVICE: eth0&#xD;<br \/>\nGENERAL.TYPE: ethernet&#xD;<br \/>\nGENERAL.HWADDR: A0:2B:B8:22:0C:6B&#xD;<br \/>\nGENERAL.MTU: 1500&#xD;<br \/>\n &#8211;&#xD;<\/p>\n<h2>5) ip route get 1.2.3.4 | awk &#8221;<\/h2>\n<p>This is yet another command that can be used to get an IP address without much statistics<\/p>\n<p>ip route get 1.2.3.4 | awk &#8221;<\/p>\n<p>Output<\/p>\n<p>192.168.43.156<\/p>\n<h2>6) Network Settings in Graphical User Interface<\/h2>\n<p>If you are running Linux in a graphical environment, you can easily navigate to the Network settings and check out the IP address. In this example, we have demonstrated this using Ubuntu 18.04 GNOME interface.<\/p>\n<ol>\n<li>Click on the Network icon as shown.<br \/><img loading=\"lazy\" decoding=\"async\" alt=\"get an IP address\" height=\"29\" src=\"https:\/\/linoxide.com\/wp-content\/uploads\/2018\/09\/network-icon1.jpg\" width=\"373\" \/><\/li>\n<li>On the pull-down menu that appears, be sure to locate the connected network interface. In this case, it&#8217;s the wired connection and we can see that the interface is up by &#8216;Wired connected&#8217; status. Click on it.<br \/><img loading=\"lazy\" decoding=\"async\" alt=\"get an IP address\" height=\"344\" src=\"https:\/\/linoxide.com\/wp-content\/uploads\/2018\/09\/network-interface1-1.jpg\" width=\"373\" \/><\/li>\n<li> Next, click on the &#8216;Wired settings&#8217; option that appears below<br \/><img loading=\"lazy\" decoding=\"async\" alt=\"get an IP address\" height=\"435\" src=\"https:\/\/linoxide.com\/wp-content\/uploads\/2018\/09\/wired-settings.jpg\" width=\"389\" \/><\/li>\n<li>This displayed a &#8216;Network Settings&#8217; window. Click on the gear icon next to the ON\/OFF toggle and a pop-up Window will appear showing the IP details of the connected network interface.<br \/><img loading=\"lazy\" decoding=\"async\" alt=\"get an IP address\" height=\"632\" src=\"https:\/\/linoxide.com\/wp-content\/uploads\/2018\/09\/ip-address-displayed.jpg\" width=\"980\" \/><\/li>\n<\/ol>\n<h2>Display a Public IP address of your Linux System<\/h2>\n<p>If you wish to get the Public IP of your Linux System, the following commands come in handy<\/p>\n<p>curl ipinfo.io\/ip&#xD;<br \/>\n&#xD;<br \/>\ncurl ifconfig.me&#xD;<br \/>\n&#xD;<br \/>\ncurl bot.whatismyipaddress.com&#xD;<br \/>\n&#xD;<br \/>\ndig +short myip.opendns.com @resolver1.opendns.com&#xD;<br \/>\n&#xD;<br \/>\ncurl checkip.dyndns.org&#xD;<br \/>\n&#xD;<br \/>\ncurl ident.me&#xD;<br \/>\n&#xD;<br \/>\nhost myip.opendns.com resolver1.opendns.com&#xD;<br \/>\n&#xD;<br \/>\ncurl ipecho.net\/plain&#xD;<\/p>\n<p>Do you know any other method to get the IP address? Please reply with your comments.<\/p>\n<h3>Read Also:<\/h3>\n<ul>\n<li><a href=\"https:\/\/linoxide.com\/linux-how-to\/how-restart-networking-ubuntu\/\" target=\"_blank\">How to Restart Networking in Ubuntu<\/a><\/li>\n<li><a href=\"https:\/\/linoxide.com\/linux-how-to\/few-command-helps-to-get-linux-hardware-details\/\" target=\"_blank\">6 Examples To Get Linux Hardware Details\/Information<\/a><\/li>\n<\/ul>\n<p> <a href=\"https:\/\/linoxide.com\/linux-how-to\/learn-how-get-linux-ip-address-different-ways\/\" target=\"_blank\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How many commands you know to get IP address on your Linux systems? In this article, we&#8217;ll discuss a few ways to get IP address as well as public IP on Linux. ifconfig command ip addr Hostname -I command nmcli command ip route Graphical Method Display Public IP address 1) ifconfig command ifconfig is short &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/17\/find-how-linux-get-ip-address-from-command\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Find How Linux Get IP Address From Command&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-321","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/321","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=321"}],"version-history":[{"count":0,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/321\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=321"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=321"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=321"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}