先用ifconfig -a查看网卡名称:
root@javie:~# ifconfig
eth2 Link encap:以太网 硬件地址 00:0c:29:14:68:7a
inet 地址:192.168.2.21 广播:192.168.2.255 掩码:255.255.255.0
inet6 地址: fe80::20c:29ff:fe14:687a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 跃点数:1
接收数据包:356079 错误:0 丢弃:0 过载:0 帧数:0
发送数据包:51 错误:0 丢弃:0 过载:0 载波:0
碰撞:0 发送队列长度:1000
接收字节:22086410 (22.0 MB) 发送字节:5230 (5.2 KB)
中断:19 基本地址:0x20a4
eth0_rename Link encap:以太网 硬件地址 00:0c:29:14:68:70
inet 地址:10.13.7.69 广播:10.255.255.255 掩码:255.0.0.0
inet6 地址: fe80::20c:29ff:fe14:6870/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 跃点数:1
接收数据包:860906 错误
然后再/etc/network/interfaces里配置如下:
root@javie:~# cat /etc/network/interfaces
auto lo eth2 eth0_rename
iface eth0_rename inet dhcp //eth0_rename 网卡动态获取
iface lo inet loopback //eth2 网卡静态配置
iface eth2 inet static
address 192.168.2.21
netmask 255.255.255.0
……
配置双IP:
1 首先ifconfig 查看 你的网卡名字是什么,如上是 eth2
2 虚拟网卡 eth2:0
auto lo auto eth2 eth2:0
#iface eth1_rename inet dhcp
iface lo inet loopback
iface eth2 inet static
address 192.168.2.21
netmask 255.255.255.0
gateway 192.168.1.1
配置虚拟网卡的ip:
iface eth2:0 inet static
address 10.13.7.71
netmask 255.0.0.0
gateway 10.13.7.254
4 重启网络
/etc/init.d/networking restart