单网卡多IP的设置问题

包含网卡/无线网的网络问题和ADSL/校园网/宽带拨号支持及代理/共享等网络使用问题
回复
mfecit
帖子: 156
注册时间: 2006-12-03 17:59

单网卡多IP的设置问题

#1

帖子 mfecit » 2008-09-01 15:47

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
"
什么意思?不同版本里的内容还不一样
TThb123
帖子: 9
注册时间: 2008-08-31 13:52

#2

帖子 TThb123 » 2008-09-01 18:40

目前为止貌似不能做到,毕竟是单网卡。
LZ是一会用光纤一会用宽带吧
最好的解决方法是用图形界面进行ip修改
反正我是没见过有谁能用windows实现单网卡实现双ip同时使用

linux中就算你加进去了也只能读一个。嫌麻烦就gedit个新文件,把两个ip全写进去。用的时候再复制粘贴吧

如果硬要解决的话windwos中编程够叼的话自己写个脚本,双击就进行切换了,在linux中的估计重新编译内核了
头像
冲浪板
论坛版主
帖子: 7513
注册时间: 2007-05-06 8:19

#3

帖子 冲浪板 » 2008-09-01 18:44

你没见过“谁能用windows实现单网卡实现双ip交换 ”?
我就用了,咋地
mfecit
帖子: 156
注册时间: 2006-12-03 17:59

#4

帖子 mfecit » 2008-09-01 20:31

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

iface eth0:0 inet static
address 192.168.1.101
netmask 255.255.255.0
gateway 192.168.1.1

auto eth0
ygf
帖子: 458
注册时间: 2006-11-27 12:25

#5

帖子 ygf » 2008-09-01 22:15

还要修改/etc/udev/rules.d/70-persistent-net.rules,增加一个eth0:0的设置,内容和eth0一样,只是将eth0改为eth0:0
头像
never
帖子: 62
注册时间: 2005-11-05 18:18
来自: 广东深圳
联系:

#6

帖子 never » 2008-09-02 10:04

我的配置如下:
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 了
mfecit
帖子: 156
注册时间: 2006-12-03 17:59

#7

帖子 mfecit » 2008-09-02 12:22

公司一个家里一个
每次回去都要手动更改 要不上不了网
主要用的是笔记本 带来带去的
头像
冲浪板
论坛版主
帖子: 7513
注册时间: 2007-05-06 8:19

#8

帖子 冲浪板 » 2008-09-02 12:26

什么系统啊,写个shell就可以了。
mfecit
帖子: 156
注册时间: 2006-12-03 17:59

#9

帖子 mfecit » 2008-09-02 12:40

冲浪板 写了:什么系统啊,写个shell就可以了。
ubuntu8.04

什么意思?怎么写?
头像
冲浪板
论坛版主
帖子: 7513
注册时间: 2007-05-06 8:19

#10

帖子 冲浪板 » 2008-09-02 14:07

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
记得设置好路由。
回复