Linux network card configuration details and examples

Time:2020-3-25

Linux network card configuration

Device = physical device name 
IPADDR = IP address 
Netmask = mask value 
Network = network address 
Broadcast = broadcast address 
Gateway = gateway address
Type = Ethernet (network type)
Onboot = [yes| no] 
Userctl = [yes| no] (can non root users control the device)
Peerdns = [yes| no] (if IP is obtained through DHCP, whether to write DNS information to / etc / resolv.conf (overwrite))
Bootproto = [none | static | BOOTP | DHCP] (do not use protocol | static allocation | BOOTP protocol | DHCP protocol when booting) 
Hwaddr = your Mac address

Example:


/etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eth0
UUID=c5300c89-c3e4-4a3a-8344-5194975eacfb
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.1.170
PREFIX=24
#GATEWAY=192.168.1.79
IPADDR1=192.168.0.170
DNS1=114.114.114.114
DNS2=202.96.128.166

 


/etc/sysconfig/network-scripts/route-eth0:
default via 192.168.0.176 dev eth0
172.16.0.0/16 via 192.168.0.200 dev eth0
192.168.105.0/24 via 192.168.1.149 dev eth0

Thank you for reading, hope to help you, thank you for your support!