Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wojciechowskimar/5f5f00e4e1502a7ed8aceb62ffffa4ed to your computer and use it in GitHub Desktop.
Save wojciechowskimar/5f5f00e4e1502a7ed8aceb62ffffa4ed to your computer and use it in GitHub Desktop.
How to configure static IP on CentOS 7

Get a list of NIC names using

ifconfig -a                                   # If you have net-tools instaled
Or
ip -a

Configure network card

vi /etc/sysconfig/network-scripts/ifcfg-en0xx # [Replace 'en0xx' with your Network Card e.g. en0]
 
NAME=eth0                                     # [Replace with your Network Card MAC Address]
HWADDR=AA:BB:CC:DD:EE:FF                      # [Replace with your Mac Address]
TYPE=Ethernet
BOOTPROTO=static
UUID=00000000-0000-0000-0000-000000000000     # [Replace with your UUDI generated by 'uuidgen <DEVICE>' example  uuidgen eth0]
NM_CONTROLLED=no                              # [IP isn't configured by Network Manager]
ONBOOT=yes
IPADDR=192.168.0.100                          # [Replace with your Device IP]
NETMASK=255.255.255.0                         # [Replace with your Network Mask]
GATEWAY=192.168.0.1                           # [Replace with your Gateway IP]

Configure Default Gateway

vi /etc/sysconfig/network
 
NETWORKING=yes
HOSTNAME=centos7                             # [Replace with your Hostname]
GATEWAY=192.168.0.1                          # [Replace with your Gateway IP]

Restart Network Interface

systemctl restart network.service

Configure DNS Server

vi /etc/resolv.conf
 
nameserver 208.67.222.222  	                # [Replace with your Nameserver IP]
nameserver 208.67.220.220  	                # [Replace with your Nameserver IP]

Configure hostname

vi /etc/hostname         
centos7.bastion.local                       # [Replace with your FQDN]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment