auto eth0 eth1
mapping eth0 eth1
script /path/to/get-mac-address.sh #启动时执行脚本get-mac-address.sh,脚本的作用就是获得每块网卡的MAC地址。
map 11:22:33:44:55:66 lan #指定MAC为11:22:33:44:55:66的网卡为lan口
map AA:BB:CCD:EE:FF internet #指定MAC为AA:BB:CCD:EE:FF的网卡为internet口,和WAN口差不多
iface lan inet static
address 192.168.42.1
netmask 255.255.255.0
pre-up /usr/local/sbin/enable-masq $IFACE
iface internet inet dhcp
pre-up /usr/local/sbin/firewall $IFACE
8、外部程序来设置ip
这段配置只是启用一个网卡,但是ifupdown不对这个网卡设置任何ip,而是由外部程序来设置ip。
57 auto eth0
58 iface eth0 inet manual
59 up ifconfig $IFACE 0.0.0.0 up
60 up /usr/local/bin/myconfigscript
61 down ifconfig $IFACE down
9、网卡的混杂模式
这段配置启用了网卡的混杂模式,用来当监听接口。
auto eth0
iface eth0 inet manual
up ifconfig $IFACE 0.0.0.0 up
up ip link set $IFACE promisc on
down ip link set $IFACE promisc off
down ifconfig $IFACE down
第三、添加DNS
编辑文件vim /etc/resolv.conf
nameserver 114.114.114.114 #替换为自己的DNS服务器地址
还可以在interfaces文件中添加dns服务器
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback