Notes – Static IP Centos 7

Check your current IP via “ip addr“. Then edit the network configuration for the interface via “nano /etc/sysconfig/network-scripts/ifcfg-ens33“.

ip addr
nano /etc/sysconfig/network-scripts/ifcfg-ens33
[root@centos7 ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:19:3f:dc brd ff:ff:ff:ff:ff:ff
    inet 10.1.1.10/24 brd 10.1.1.255 scope global noprefixroute dynamic ens33
       valid_lft 85694sec preferred_lft 85694sec
    inet6 fe80::646c:c46d:9e06:7bf6/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
[root@centos7 ~]#
[root@centos7 ~]# nano /etc/sysconfig/network-scripts/ifcfg-ens33

You’ll see the following and will need to edit the highlighted and add the static IP values.

  GNU nano 2.3.1             File: /etc/sysconfig/network-scripts/ifcfg-ens33

TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="dhcp"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="90defcec-ea18-4412-a86f-5a9210ddbeb5"
DEVICE="ens33"
ONBOOT="yes"




                                              [ Read 15 lines ]
^G Get Help       ^O WriteOut       ^R Read File      ^Y Prev Page      ^K Cut Text       ^C Cur Pos
^X Exit           ^J Justify        ^W Where Is       ^V Next Page      ^U UnCut Text     ^T To Spell
  GNU nano 2.3.1             File: /etc/sysconfig/network-scripts/ifcfg-ens33

TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static"
IPADDR=10.1.1.100
NETMASK=255.255.255.0
GATEWAY=10.1.1.1
DNS1=8.8.8.8
DNS2=1.1.1.1
DNS3=8.8.4.4
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="90defcec-ea18-4412-a86f-5a9210ddbeb5"
DEVICE="ens33"
ONBOOT="yes"




                                              [ Read 21 lines ]
^G Get Help       ^O WriteOut       ^R Read File      ^Y Prev Page      ^K Cut Text       ^C Cur Pos
^X Exit           ^J Justify        ^W Where Is       ^V Next Page      ^U UnCut Text     ^T To Spell

Ctrl + X, then save when prompted.

Lastly, we’ll need to restart network service via “service network restart

service network restart
[root@centos7 ~]# service network restart
Restarting network (via systemctl):                        [  OK  ]
[root@centos7 ~]#
[root@centos7 ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:19:3f:dc brd ff:ff:ff:ff:ff:ff
    inet 10.1.1.100/24 brd 10.1.1.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::646c:c46d:9e06:7bf6/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
[root@centos7 ~]#
Return to Notes list

Leave a Reply