NETWORKING IN LINUX

View existing hostname in Linux


[user1@localhost~]$hostname
localhost.localdomain
      

Setup hostname for temporarily


[root@localhost~]#hostname Linux1.example.com

View IP configuration


                                    
[root@Linux1~]#ifconfig
      

Manually resolve hostname and IP address


[root@localhost~]#vi /etc/hosts
192.168.1.100 Linux1.example.com Linux1
      

Setup Server IP address temporarily


[root@Linux1~]#ifconfig <network_device_name> <IP
address> netmask <netmask_value>
Example:
[root@Linux1~]#ifconfig enp1s7 192.168.1.100 netmask
255.255.255.0
      

Setup an IP address- Manual/Automatic


                                    
[root@Linux1~]#nmtui
Select Edit Connection
Select devices –Edit
Select Static (Manual method)
Configure IP Address ,Subnet Mask, DNS Server and
Default Gateway IP Address
Select Quit to proceed
      

Restarting Network Service to apply new configuration

CentOS 7/RHEL 7


#service network restart
#systemctl start network
#systemctl enable network
      

CentOS 8/9 RHEL 8/9


#systemctl start NetworkManager.service
#systemctl stop NetworkManager.service
#systemctl restart NetworkManager.service
#systemctl status NetworkManager.service
  

Enable/disable Lan network


[root@Linux1~]#ifdown enp1s1
[root@Linux1~]#ifup enp1s1
[root@Linux1~]#ifconfig    
     

Monitor network statistics

The ss (socket statistics) command is a powerful tool in Linux used for examining sockets. Socket = (TCP Port + IP Address)


[root@Linux1~]#ss –ta
   

Display status of all network devices


Display only Active connections