Redhat has made a lot of changes in the RHEL-7’s networking part. In Red Hat Enterprise Linux 7, the default networking service is provided by NetworkManager, which is a dynamic network control and configuration daemon that attempts to keep network devices and connections up and active when they are available. The traditional ifcfg type configuration files are still supported. To view the current network configuration, you need to use the command called “ip” . Still “ifconfig” command is operational but moving forward, we may need to use /sbin/ip and nmcli commands. In this article ,we will see that how to review the current network configuration and checking open ports and listening services. 1.To display the current IP address configured on the system, use the below command.
[root@server1-UA ~]#ip add show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 52:54:00:00:01:0b brd ff:ff:ff:ff:ff:ff inet 172.25.2.251/16 brd 172.25.255.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::5054:ff:fe00:10b/64 scope link valid_lft forever preferred_lft forever [root@server1-UA ~]#
2. To see the specific interface IP address on the RHEL-7, use the below mentioned command.
[root@server1-UA ~]#ip add show eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 52:54:00:00:01:0b brd ff:ff:ff:ff:ff:ff inet 172.25.2.251/16 brd 172.25.255.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::5054:ff:fe00:10b/64 scope link valid_lft forever preferred_lft forever [root@server1-UA ~]#
UP – It indicates that interface is Active currently. link/ether – Shows the MAC address of the network card/interface. inet – Show the IPV4 ip-address for the interface , subnet mask and broadcast address. inet6- shows the IPV6 information. 3. To see the specific link statistics , use the IP command.
[root@server1-UA ~]#ip -s link show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 RX: bytes packets errors dropped overrun mcast 556 8 0 0 0 0 TX: bytes packets errors dropped carrier collsns 556 8 0 0 0 0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000 link/ether 52:54:00:00:01:0b brd ff:ff:ff:ff:ff:ff RX: bytes packets errors dropped overrun mcast 339864 3299 0 0 0 0 TX: bytes packets errors dropped carrier collsns 38372 384 0 0 0 0 [root@server1-UA ~]#
To show the statistics of specific link,
[root@server1-UA ~]#ip -s link show eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000 link/ether 52:54:00:00:01:0b brd ff:ff:ff:ff:ff:ff RX: bytes packets errors dropped overrun mcast 341297 3314 0 0 0 0 TX: bytes packets errors dropped carrier collsns 39902 391 0 0 0 0 [root@server1-UA ~]#
4. To view the routing information , use ip route command.
[root@server1-UA ~]#ip route 172.25.0.0/16 dev eth0 proto kernel scope link src 172.25.2.251 [root@server1-UA ~]#
5.In RHEL 7 ,You need to use the tracepath command to trace the path to a remote host. Still traceroute command is operational , but tracepath provides the additional information like RTT(Round Trip timing) and MTU(Maximum Transfer Unit).
[root@server1-UA ~]#tracepath 172.25.2.250 1: classroom.example.com 2.451ms reached Resume: pmtu 65535 hops 1 back 64 [root@server1-UA ~]#
6.In RHEL 7 , “ss” command is used to display the socket statistics. “ss” is an just replacement of “netstat” command.
[root@server1-UA ~]#ss -ta State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 100 127.0.0.1:smtp *:* LISTEN 0 128 *:sunrpc *:* LISTEN 0 128 *:44338 *:* LISTEN 0 128 *:ssh *:* ESTAB 0 0 172.25.2.251:ssh 172.25.2.250:55682 LISTEN 0 100 ::1:smtp :::* LISTEN 0 128 :::sunrpc :::* LISTEN 0 128 :::47568 :::* LISTEN 0 128 :::ssh :::* [root@server1-UA ~]#
If the systems are using the network manager , You can use the below mentioned commands to view the network information . 1. To display a list of all connections , use “nmcli con show” command.
[root@server1-UA ~]# nmcli con show NAME UUID TYPE DEVICE System eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 802-3-ethernet eth0 [root@server1-UA ~]#
2. To display the specific connection details, use the below command.
[root@server1-UA ~]# nmcli con show NAME UUID TYPE DEVICE System eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 802-3-ethernet eth0 [root@server1-UA ~]# nmcli con show "System eth0" connection.id: System eth0 connection.uuid: 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 connection.interface-name: eth0 connection.type: 802-3-ethernet connection.autoconnect: yes connection.timestamp: 1429599144 connection.read-only: no connection.permissions: connection.zone: -- connection.master: -- connection.slave-type: -- connection.secondaries: connection.gateway-ping-timeout: 0 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 802-3-ethernet.duplex: -- 802-3-ethernet.auto-negotiate: yes 802-3-ethernet.mac-address: -- 802-3-ethernet.cloned-mac-address: -- 802-3-ethernet.mac-address-blacklist: 802-3-ethernet.mtu: auto 802-3-ethernet.s390-subchannels: 802-3-ethernet.s390-nettype: -- 802-3-ethernet.s390-options: ipv4.method: manual ipv4.dns: 172.25.2.250 ipv4.dns-search: example.com ipv4.addresses: { ip = 172.25.2.251/16, gw = 0.0.0.0 } ipv4.routes: ipv4.ignore-auto-routes: no ipv4.ignore-auto-dns: yes ipv4.dhcp-client-id: -- ipv4.dhcp-send-hostname: yes ipv4.dhcp-hostname: -- ipv4.never-default: no ipv4.may-fail: yes ipv6.method: ignore ipv6.dns: ipv6.dns-search: ipv6.addresses: ipv6.routes: ipv6.ignore-auto-routes: no ipv6.ignore-auto-dns: no ipv6.never-default: no ipv6.may-fail: yes ipv6.ip6-privacy: -1 (unknown) ipv6.dhcp-hostname: -- GENERAL.NAME: System eth0 GENERAL.UUID: 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 GENERAL.DEVICES: eth0 GENERAL.STATE: activated GENERAL.DEFAULT: no GENERAL.DEFAULT6: no GENERAL.VPN: no GENERAL.ZONE: -- GENERAL.DBUS-PATH: /org/freedesktop/NetworkManager/ActiveConnection/0 GENERAL.CON-PATH: /org/freedesktop/NetworkManager/Settings/0 GENERAL.SPEC-OBJECT: -- GENERAL.MASTER-PATH: -- IP4.ADDRESS[1]: ip = 172.25.2.251/16, gw = 0.0.0.0 IP4.DNS[1]: 172.25.2.250 IP6.ADDRESS[1]: ip = fe80::5054:ff:fe00:10b/64, gw = :: [root@server1-UA ~]#
3.To display the Ethernet status/device status, use “nmcli dev status” command.
[root@server1-UA ~]#nmcli dev status DEVICE TYPE STATE CONNECTION eth0 ethernet connected System eth0 lo loopback unmanaged -- [root@server1-UA ~]#
4. To check the specific device status in detail, use the below command.
[root@server1-UA ~]#nmcli dev show eth0 GENERAL.DEVICE: eth0 GENERAL.TYPE: ethernet GENERAL.HWADDR: 52:54:00:00:01:0B GENERAL.MTU: 1500 GENERAL.STATE: 100 (connected) GENERAL.CONNECTION: System eth0 GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/0 WIRED-PROPERTIES.CARRIER: on IP4.ADDRESS[1]: ip = 172.25.2.251/16, gw = 0.0.0.0 IP4.DNS[1]: 172.25.2.250 IP6.ADDRESS[1]: ip = fe80::5054:ff:fe00:10b/64, gw = :: [root@server1-UA ~]#
Hope this article is informative to you . In the next article, we will see that how to create the network connections using nmcli.
Michel says
How to clean interface statistics? “ip -s link show xxx”.
Lingeswaran R says
unfortunately , you need to reboot the system to clear the statistics.
Otherwise , you can follow the below.
1. Find the driver name using ethtool for the interface.
[root@server1-UA ~]#ethtool -i eth0
driver: virtio_net
version: 1.0.0
firmware-version:
bus-info: 0000:00:03.0
supports-statistics: no
supports-test: no
supports-eeprom-access: no
supports-register-dump: no
supports-priv-flags: no
[root@server1-UA ~]#
2.Check the loaded modules for the driver .
[root@server1-UA ~]#modprobe -D virtio_net
insmod /lib/modules/3.10.0-123.el7.x86_64/kernel/drivers/virtio/virtio.ko
insmod /lib/modules/3.10.0-123.el7.x86_64/kernel/drivers/virtio/virtio_ring.ko
insmod /lib/modules/3.10.0-123.el7.x86_64/kernel/drivers/net/virtio_net.ko
[root@server1-UA ~]#
3.Here is my current statistics of the link.(eth0) mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
[root@server1-UA ~]#ip -s link show eth0
2: eth0:
link/ether 52:54:00:00:01:0b brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
776538 7495 0 0 0 0
TX: bytes packets errors dropped carrier collsns
477941 2985 0 0 0 0
[root@server1-UA ~]#
4.Login to the system console and Unload the eth0 driver. (System will be disconnected from network)
[root@server1-UA ~]#modprobe -r virtio_net
[root@server1-UA ~]#
5.Reload the driver again. mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
[root@server1-UA ~]#modprobe virtio_net
[root@server1-UA ~]#
[root@server1-UA ~]#
[root@server1-UA ~]#ip -s link show eth0
3: eth0:
link/ether 52:54:00:00:01:0b brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
7888 79 0 0 0 0
TX: bytes packets errors dropped carrier collsns
7950 71 0 0 0 0
[root@server1-UA ~]#
Hope this helps.