Network Configuration in Linux Machine using Command - CentOS

CentOS/RHEL - Static IP Configuration

Network Configuration in Linux Machine - CLI

Manual Entry – static IP - CentOS/RHEL

To know the hostname /etc/hostname

To know the system assigned IP and interface card: # ip a

Check the network card file and edit the file to update the network information.

List the file under the network-scripts directory.  # ls /etc/sysconfig/network-scripts

Edit the file. # vi /etc/sysconfig/network-scripts/ifcg-enth0

  • BOOTPROTO=static
  • ONBOOT=yes

After changing the options given above, append the following lines: 

  • IPADDR=192.168.*.*
  • NETMASK=255.255.255.0
  • GATEWAY=192.168.*.*
  • DNS1=192.168.*.*

Add the full domain controller name in the /etc/hosts file **Optional**

  • echo 192.168.1.10 dc01.domainname  >> /etc/hosts à To add an entry without opening the file.
  • Vi /etc/hosts àOpen the vi editor and add an entry.
    • press “I” and add entry and press “esc :wq!” enter to save and exit.
  • cat /etc/hosts à To list content of the file .

Add domain controller IP address to /etc/ resolv.conf.

  • search Fulldomainname
  • nameserver DNSServerIPaddress
  • domain domainname **Optional**
  • nameserver defaultgatewayIP **Optional**

Restart the networking service: Use the following command in CentOS 

  • systemctl restart NetworkManager.service
  • systemctl status NetworkManager.service


Comments