In this post I am going to show how to do network configuration in rhel7/centos7. We have ip command introduced in linux way back but we never used it. In this post we will use ip related commands which isnot easy to use as it has many options need to provide to get relevant output.
to see IP address details normally we used ifconfig command we check the same using ip addr show command.
Here we an see ipv4 address of eth0 interface along with ipv6 address and network UP status and mtu size.
we can check routing information using ip route command.
here default route is 192.168.122.1 for device eth0.
We can even check the network throughput from any network interface. Network performance can be checked using ip -s link command.
Here transfer bytes and received bytes are showing and it also shows errors dropped packets.
We can do troubleshooting of port and service using netstat or ss commands.
in this output we can see all listening tcp/udp running services and its related port numbers.
-t — show tcp sockets
-u — show udp sockets
-l — show only listening sockets
-p — show process names using that sockets
-e — show extended information like user and inode number of sockets
-n — show number instead of names.
We can add IP address using ip addr command.
we can add route as well using ip route add
BUT changes made through ip commands will not survive after reboot of NetworkManager or server.
We use nmcli command to make changes permanently or we can edit configuration file directly from /etc/sysconfi/network-scripts location to make network modification permanent.
in nimcli we have concept of connection. A connection is configuration used for a device which is made up of collection of setting.
To see existing connections on server use nmcli con show
We can check status of device where it connected or not.
Now we will add one connection dhcp_test which will autoconnect as ethernet connection
now we will add one more connection static_test which will not autoconnect and we need to specify IP and gateway address.
“–” shows connection dhcp_test and static_test is not active presently.
We can activate static connection now using nmcli con up
At any time only one connection will be active on Ethernet interface.
We can modify connection properties using nmcli con mod . Following are connection properties for static_test.
Here connection.autoconnect is set to no. We want to make this connection to autoconnect to yes.
You can delete any connection created using nmcli con del
We can perform these addition and modification of network configuration using nmtui text user interface tool as well.
Good Luck for Networking in RHEL7.