Debian网卡配置Linux 2010-04-02 16:18:53 阅读17 评论0 字号:大中小 .
1.单网卡配置
/etc/network/interfaces
auto eth0
#iface eth0 inet dhcp(默认是DHCP被注释掉)
iface eth0 inet static
address 192.168.8.110
netmask 255.255.255.0
gateway 192.168.8.1
2.双网卡配置
/etc/network/interfaces
auto eth0
#iface eth0 inet dhcp(默认是DHCP被注释掉)
iface eth0 inet static
address 192.168.8.110
netmask 255.255.255.0
gateway 192.168.8.1
auto eth1
iface eth1 inet static
address 192.168.0.110
netmask 255.255.255.0
gateway 192.168.8.1
(注意eth1没有gateway )
3.单网卡配置多ip
修改/etc/network/interfaces
auto eth0
iface eth0 inet static
address192.168.8.110
netmask 255.255.255.0
gateway 192.168.8.1
auto eth0:0
iface eth0:0 inet static
address 192.168.0.110
netmask 255.255.255.0
修改/etc/network/ifstate
lo=lo
eth0=eth0
eth0:0=eth0:0
如果没有/etc/network/ifstate,手工创建
#/etc/init.d/networking restart
注意,eth0:0没有gateway,此方法测试有效,以下还有来自网上的方法还未尝试
方法一:
修改/etc/network/interfaces
auto eth0
iface eth0 inet static
address192.168.8.110
netmask 255.255.255.0
gateway 192.168.8.1
up route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.8.1
down route del -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.8.1
方法二:
在/etc/network/if-up.d目录下建立一个简单的脚本,如static-route$
(记得以$结尾,要不有个run-parts会报错)脚本越简单越好
#!/bin/bash
route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.8.1
转载于:https://blog.51cto.com/gxjluck/350711