Detailed explanation of network card configuration and example code sharing under Linux

黄舟
Release: 2017-06-01 11:01:23
Original
1887 people have browsed it

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地址
Copy after login

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
Copy after login
/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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template