CentOS Network Script Configuration Tutorial

The Network Script section contains the Network Interface Card (NIC) related configuration, such as setup network IP Address, various protocol static, DHCP, can control IP address version IPV4 pr IPV6.


Useful command for network configuration

  • nmcli is used to create, display, edit, delete, activate, and deactivate network connections, as well as control and display network device status.

  • ifdown : Take a network interface down

  • ifup : Bring a network interface up


Network Interface Naming Convention

Based on the device type, the network interface name can start with:

  • en : Ethernet interface

  • wl : Wlan interface

  • ww : Wwam interface

  • sl : Serial line IP (slip)


Example Network Interface Configuration Example

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no

NAME=eth0
DEVICE=eth0

BOOTPROTO=none
ONBOOT=yes

IPADDR=192.168.1.200
NETMASK=255.255.255.0
PREFIX=24
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=4.2.2.2


Here

  • BOOTPROTO : Protocol used in startup

    • none : No boot-time protocol should be used.

    • bootp : The BOOTP protocol should be used.

    • dhcp : The DHCP protocol should be used.

  • ONBOOT : When should active the device.

    • yes : This device should be activated at boot-time.

    • no : This device should not be activated at boot-time.

  • IPADDR : Where address is the IPv4 address

  • NETMASK : Define the class and range of Internet Protocol (IP) addresses.

  • PREFIX : Number of bits in IPADDR that form the network address. If specify NETMASK then no need to use this.

  • GATEWAY : IPV4 default path for go out.

  • DNSx : Specify the DNS server of IPV4 address.

  • NAME : The interface name

  • DEVICE : The device name

  • TYPE : Type of the device


Usable Network Interface Configuration for static IP Address

Before copy & paste the following example codes please change the following parameter accordion to your hardware.

TYPE=Ethernet

PROXY_METHOD=none
BROWSER_ONLY=no
DEFROUTE=yes


IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy

NAME=ens33
DEVICE=ens33


ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.1.150
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=4.2.2.2

IPV4_FAILURE_FATAL=no