Home > Article > Operation and Maintenance > Detailed explanation of network card configuration and example code sharing under Linux
This article mainly introduces the detailed explanation and examples of linux network card configuration. Friends in need can refer to
linux network card configuration
DEVICE=物理设备名 IPADDR=IP地址 NETMASK=掩码值 NETWORK=网络地址 BROADCAST=广播地址 GATEWAY=网关地址 TYPE=Ethernet (网络类型) ONBOOT=[yes|no](引导时是否激活设备) USERCTL=[yes|no](非root用户是否可以控制该设备) PEERDNS=[yes|no] (如果通过 DHCP 获取 IP ,是否将 DNS 信息写入 /etc/resolv.conf (覆盖)) BOOTPROTO=[none|static|bootp|dhcp](引导时不使用协议|静态分配|BOOTP协议|DHCP协议) HWADDR = 你的MAC地址
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
The above is the detailed content of Detailed explanation of network card configuration and example code sharing under Linux. For more information, please follow other related articles on the PHP Chinese website!