linux网卡

当网卡配置脚本处于 DHCP 获取 IP 时。

cat ifcfg-e3

DEVICE=e3

HWADDR=00:0c:29:ca:1c:7a

TYPE=Ethernet

ONBOOT=yes

NM_CONTROLLED=yes

BOOTPROTO=dhcp

IPV6INIT=no

USERCTL=no

PEERDNS=yes



||||||||||||||||||||||||||||||||||||||||||||||||||||||||


# cat /etc/udev/rules.d/70-persistent-net.rules

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:ca:1c:66", ATTR{type}=="1", KERNEL=="eth*", NAME="e1"

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:ca:1c:70", ATTR{type}=="1", KERNEL=="eth*", NAME="e2"


# /etc/init.d/udev-post start

Retrigger failed udev events                               [  OK  ]


# cat /etc/sysconfig/network-scripts/ifcfg-e1

DEVICE=e1

HWADDR=00:0c:29:ca:1c:66

TYPE=Ethernet

# UUID=

ONBOOT=yes

NM_CONTROLLED=yes

BOOTPROTO=none

IPADDR=192.168.136.128

NETMASK=255.255.255.0

DNS2=111.11.11.1

GATEWAY=192.168.136.1

DNS1=8.8.8.8

IPV6INIT=no

USERCTL=no

#00:0c:29:ca:1c:66 e1

#00:0c:29:ca:1c:70 e2


# cat /etc/sysconfig/network-scripts/ifcfg-e2

DEVICE=e2

HWADDR=00:0c:29:ca:1c:70

TYPE=Ethernet

# UUID=

ONBOOT=yes

NM_CONTROLLED=yes

BOOTPROTO=none

IPADDR=192.168.136.127

NETMASK=255.255.255.0

#DNS2=111.11.11.1

#GATEWAY=192.168.136.1

#DNS1=8.8.8.8

IPV6INIT=no

USERCTL=no

#00:0c:29:ca:1c:66 e1

#00:0c:29:ca:1c:70 e2


* 直接生效

----------------------------------------------------

wKioL1Sb5M7TMDYMAADGCKHiJkQ375.jpg





||||||||||||||||||||||||||||||||||||||||||||||||||||||||

添加一个虚拟网络接口

# cd /etc/sysconfig/network-scripts

# cp ifcfg-e3 ifcfg-e3:1


# vi ifcfg-e3:1

修改成:

DEVICE=e3:1
ONPARENT=yes



||||||||||||||||||||||||||||||||||||||||||||||||||||||||


网卡脚本的 DNS 可以统一设定:

$ cat /etc/sysconfig/network

HOSTNAME=h1

DNS1=111.11.11.1

DNS2=8.8.8.8

#HOSTNAME=h1.sunny.com

#SEARCH=sunny.com


||||||||||||||||||||||||||||||||||||||||||||||||||||||||


单网卡多IP

DEVICE=e2

HWADDR=00:0c:29:ca:1c:70

TYPE=Ethernet

ONBOOT=yes

NM_CONTROLLED=yes

BOOTPROTO=none

#IPADDR=10.97.57.3

IPADDR1=192.168.3.240

IPADDR2=10.97.57.5

NETMASK1=255.255.0.0

NETMASK2=255.255.255.0

DNS1=111.11.11.1

GATEWAY=10.97.57.1

DNS2=8.8.8.8

IPV6INIT=no

USERCTL=no





本文出自 “小崔的实验笔记” 博客,谢绝转载!

你可能感兴趣的:(linux,网卡,Address)