More commands to get information about your network adapter.

There are a few commands available in Red Hat Linux to get information about your network adapter. Here are a couple.

The ifstat command returns information about the network throughput of your adapter.

[jason@darknet ~]$ ifstat 
#kernel
Interface        RX Pkts/Rate    TX Pkts/Rate    RX Data/Rate    TX Data/Rate  
                 RX Errs/Drop    TX Errs/Drop    RX Over/Rate    TX Coll/Rate  
lo                     0 0             0 0             0 0             0 0      
                       0 0             0 0             0 0             0 0      
eno16777736          131 0           139 0         42259 0         17036 0      
                       0 0             0 0             0 0             0 0      
virbr0                 0 0             0 0             0 0             0 0      
                       0 0             0 0             0 0             0 0

The familiar ifconfig command will return information about your network adapter.

[jason@darknet ~]$ ifconfig eno16777736
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.85.148  netmask 255.255.255.0  broadcast 192.168.85.255
        inet6 fe80::20c:29ff:fe47:5eb4  prefixlen 64  scopeid 0x20<link>
        inet6 fd15:4ba5:5a2b:1008:20c:29ff:fe47:5eb4  prefixlen 64  scopeid 0x0<global>
        ether 00:0c:29:47:5e:b4  txqueuelen 1000  (Ethernet)
        RX packets 118  bytes 22310 (21.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 129  bytes 22942 (22.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

The netstat command lists all connections in and out of the network. The snippet below shows listening connections on a Red Hat Enterprise Linux VM.

[jason@darknet ~]$ netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 192.168.122.1:domain    0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN     
tcp        0      0 localhost:ipp           0.0.0.0:*               LISTEN     
tcp        0      0 localhost:smtp          0.0.0.0:*               LISTEN     
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN     
tcp6       0      0 localhost:ipp           [::]:*                  LISTEN     
tcp6       0      0 localhost:smtp          [::]:*                  LISTEN     
udp        0      0 0.0.0.0:15267           0.0.0.0:*                          
udp        0      0 192.168.122.1:domain    0.0.0.0:*                          
udp        0      0 0.0.0.0:bootps          0.0.0.0:*                          
udp        0      0 0.0.0.0:bootpc          0.0.0.0:*                          
udp        0      0 0.0.0.0:49275           0.0.0.0:*                          
udp        0      0 0.0.0.0:mdns            0.0.0.0:*                          
udp        0      0 localhost:323           0.0.0.0:*                          
udp6       0      0 [::]:41981              [::]:*                             
udp6       0      0 localhost:323           [::]:*                             
raw6       0      0 [::]:ipv6-icmp          [::]:*                  7

The ip addr show command will also return your IP address.

[jason@darknet ~]$ ip addr show eno16777736 | grep inet
    inet 192.168.85.148/24 brd 192.168.85.255 scope global dynamic eno16777736
    inet6 fd15:4ba5:5a2b:1008:20c:29ff:fe47:5eb4/64 scope global noprefixroute dynamic 
    inet6 fe80::20c:29ff:fe47:5eb4/64 scope link

This is yet another way to return your IP address of a LAN connected machine.

[jason@darknet ~]$ hostname -I
192.168.85.148 192.168.122.1 fd15:4ba5:5a2b:1008:20c:29ff:fe47:5eb4

This command will return the external IP address of your Linux machine.

[jason@darknet ~]$ curl http://ipecho.net/plain; echo
52.XX.XXX.XX

These commands will make it very easy to get network IP information quickly. This is how flexible Linux is in regards to combining commands and piping to make sure you only return the information you want from a command.

No comments have been made. Use this form to start the conversation :)

Leave a Reply