Ifconfig

From Dikapedia
Jump to: navigation, search


ifconfig - *technically obsolete (use ip addr instead)* Show interface info, IP address, mac address, etc.



$ sudo ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:17:42:1f:18:be
          inet addr:10.1.1.7  Bcast:10.1.1.255  Mask:255.255.255.0
          inet6 addr: fe80::217:42ff:fe1f:18be/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:1 errors:0 dropped:0 overruns:0 frame:0
          TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:229 (229.0 B)  TX bytes:2178 (2.1 KB)
          Interrupt:10


Probably the most important line in this is the second line of output, which tells us our host has an IP address (10.1.1.7) and subnet mask (255.255.255.0) configured.


On my RHEL 7:

$ ifconfig -a
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9001
        inet 172.31.0.84  netmask 255.255.240.0  broadcast 172.31.15.255
        inet6 fe80::25:dbff:fe74:d054  prefixlen 64  scopeid 0x20<link>
        ether 02:25:db:74:d0:54  txqueuelen 1000  (Ethernet)
        RX packets 12244412  bytes 7608627959 (7.0 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 55456567  bytes 78290759008 (72.9 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 142  bytes 10748 (10.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 142  bytes 10748 (10.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


Troubleshooting



After determining that your server is physically connected to the network, next check if your network interface is configured properly.


Now figuring out if the settings for your server are correct, that is something you will need to confirm. If the interface is not configured, try running the following command to see if the interface comes up:

$ sudo ifup eth0
$ sudo ifconfig


If the settings are wrong or the interface won’t come up, inspect /etc/network/interfaces on Debian-based systems or /etc/sysconfig/network_scripts/ifcfg-<interface> on Red Hat-based systems. It is in these files that you can correct any errors in the network settings.


Now if the host gets its IP through DHCP, you will need to move your troubleshooting to the DHCP host to find out why you aren’t getting a lease.