ubuntu8.04
vi /etc/network/interfaces
"
auto lo
iface lo inet loopback
iface eth0 inet static
address 20.10.0.161
netmask 255.0.0.0
gateway 20.10.0.1
auto eth0
"
在上面的文件中如何将下面的追加进来,从而实现双IP
iface eth0:0 inet static
address 192.168.1.101
netmask 255.255.255.0
gateway 192.168.1.1
"
auto lo
iface lo inet loopback
auto eth0
"
什么意思?不同版本里的内容还不一样
单网卡多IP的设置问题
-
- 帖子: 156
- 注册时间: 2006-12-03 17:59
-
- 帖子: 9
- 注册时间: 2008-08-31 13:52
-
- 帖子: 156
- 注册时间: 2006-12-03 17:59
-
- 帖子: 458
- 注册时间: 2006-11-27 12:25
- never
- 帖子: 62
- 注册时间: 2005-11-05 18:18
- 来自: 广东深圳
- 联系:
我的配置如下:
qnofae@suromail2:~$ cat /etc/network/interfaces
# 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
# The primary network interface
auto eth0
# iface eth0 inet dhcp
iface eth0 inet static
address 172.16.16.15
network 172.16.16.0
broadcast 172.16.16.255
netmask 255.255.255.0
gateway 172.16.16.1
metric 0
iface eth0:0 inet static
address 172.20.20.15
netmask 255.255.255.0
auto eth0:0
qnofae@suromail2:~$
这样启动系统之后就有两个IP了,关键是不能同时有两个网关,如果需要另外的网关,就要使用 route 了
qnofae@suromail2:~$ cat /etc/network/interfaces
# 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
# The primary network interface
auto eth0
# iface eth0 inet dhcp
iface eth0 inet static
address 172.16.16.15
network 172.16.16.0
broadcast 172.16.16.255
netmask 255.255.255.0
gateway 172.16.16.1
metric 0
iface eth0:0 inet static
address 172.20.20.15
netmask 255.255.255.0
auto eth0:0
qnofae@suromail2:~$
这样启动系统之后就有两个IP了,关键是不能同时有两个网关,如果需要另外的网关,就要使用 route 了
- 冲浪板
- 论坛版主
- 帖子: 7513
- 注册时间: 2007-05-06 8:19
ifdown eth0
ifconfig eth0 192.168.1.99 broadcast 192.168.1.255 netmask 255.255.255.0
ifup eth0
btw: 同样
ifconfig eth0 down
ifconfig eth0 192.168.1.99 broadcast 192.168.1.255 netmask 255.255.255.0
ifconfig eth0 up
这个也成
ifconfig eth0 192.168.1.99 broadcast 192.168.1.255 netmask 255.255.255.0 up
其实你可以设置两个ip给这个网卡,等于虚拟出另一个网卡
ifconfig eth0:1 192.168.2.9 broadcast 192.168.2.255 netmask 255.255.255.0 up
记得设置好路由。
ifconfig eth0 192.168.1.99 broadcast 192.168.1.255 netmask 255.255.255.0
ifup eth0
btw: 同样
ifconfig eth0 down
ifconfig eth0 192.168.1.99 broadcast 192.168.1.255 netmask 255.255.255.0
ifconfig eth0 up
这个也成
ifconfig eth0 192.168.1.99 broadcast 192.168.1.255 netmask 255.255.255.0 up
其实你可以设置两个ip给这个网卡,等于虚拟出另一个网卡
ifconfig eth0:1 192.168.2.9 broadcast 192.168.2.255 netmask 255.255.255.0 up
记得设置好路由。