Centos 7 - How to static ip
A quick guide, how to configure an static ip with Centos 7.
First we need to know witch hardware is used to your internet connection (Ethernet, WIFI, 3G):
ifconfig # check if eno1, eth1 or wlan1 are up:
Then check the status of your Network Manager and stop the service:
su -c 'service NetworkManager status'
su -c 'service NetworkManager stop'
Then you will need to configure the file
su -c 'nano /etc/sysconfig/network'
NETWORKING=yes NETWORKING_IPV6=no HOSTNAME=your_hostname GATEWAY=your_gateway
Now you will need to configure the script
*eno0cd depends of your hardware, this is for an Ethernet connection, you should check which match your device.
su -c 'nano /etc/sysconfig/network-scripts/ifcfg-eno0cd'
DEVICE=your_device BOOTPROTO=static BROADCAST=your_broadcast IPADDR=your_wanted_ip NETMASK=your_netmask NETWORK=your_network DNS1=22.214.171.124 # if you want to use opendns DNS2=126.96.36.199 # if you want to use opendns ONBOOT=yes
Example of a good configuration for a simple Network:
DEVICE=eno1 BOOTPROTO=static BROADCAST=192.168.0.255 IPADDR=192.168.0.78 NETMASK=255.255.255.0 NETWORK=192.168.0.0 DNS1=188.8.131.52 DNS2=184.108.40.206 ONBOOT=yes
Now if you want to configure your DNS server, you need to configure
su -c 'nano /etc/resolv.conf'
#Generated by NetworkManager nameserver 220.127.116.11 nameserver 18.104.22.168
Now you can restart the Network Manager services:
su -c 'service network restart'
su -c 'init 6' # retart server