LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1846|回复: 3

FreeBSD一网卡配双IP问题。

[复制链接]
发表于 2003-12-16 22:35:59 | 显示全部楼层 |阅读模式
我用的是FreeBSD 5.0系统,我在一块网卡上配双IP地址时,输入命令
ifconfig lnc0 alias 192.168.1.55 netmask 255.255.255.0
                                       (lnc0为网卡名称)
系统提示: ifconfig:ioct1(SIOCAIFADDR):File exists
这个提示是什么意思?应该怎么解决?

我还编辑过 /etc/rc.conf文件
在网卡配置行内新加入一行:
  ifconfig_lnc0_alias0="inet 192.168.1.55 netmask 255.255.255.0"
重新启动系统后仍然还是一个IP地址。

麻烦问一下,单网卡配置双IP地址应该怎么配置?(最好说具体点)


谢谢!
发表于 2003-12-17 08:02:41 | 显示全部楼层
I don't have any trouble to set an alias,
my network interface is dc0

laptop# ifconfig dc0
dc0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        inet6 fe80::210:a4ff:fe9b:6cd7%dc0 prefixlen 64 scopeid 0x3
        inet 192.168.1.10 netmask 0xffffff00 broadcast 192.168.1.255
        ether 00:10:a4:9b:6c:d7
        media: Ethernet autoselect (100baseTX <full-duplex>)
        status: active

laptop# ifconfig dc0 alias 10.73.125.120 netmask 255.255.255.0
laptop#
laptop# ifconfig dc0
dc0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        inet6 fe80::210:a4ff:fe9b:6cd7%dc0 prefixlen 64 scopeid 0x3
        inet 192.168.1.10 netmask 0xffffff00 broadcast 192.168.1.255
        inet 10.73.125.120 netmask 0xffffff00 broadcast 10.73.125.255
        ether 00:10:a4:9b:6c:d7
        media: Ethernet autoselect (100baseTX <full-duplex>)
        status: active
laptop#


Conclusion: the only trouble you could have is:
     alias   Establish an additional network address for this interface.  This is sometimes useful when changing network numbers, and one wishes to accept packets addressed to the old interface.  If the address is on the same subnet as the first network address for this interface, a non-conflicting netmask must be given.  Usually  0xffffffff is most appropriate.

shortly, if your alias is on the same subnet with first network, netmask should be 255.255.255.255, not 255.255.255.0
发表于 2003-12-17 08:23:27 | 显示全部楼层
Note that alias entries must start with alias0 and proceed upwards in order, (for example, _alias1, _alias2, and so on). The configuration process will stop at the first missing number.

The calculation of alias netmasks is important, but fortunately quite simple. For a given interface, there must be one address which correctly represents the network's netmask. Any other addresses which fall within this network must have a netmask of all 1s.

For example, consider the case where the fxp0 interface is connected to two networks, the 10.1.1.0 network with a netmask of 255.255.255.0 and the 202.0.75.16 network with a netmask of 255.255.255.240. We want the system to appear at 10.1.1.1 through 10.1.1.5 and at 202.0.75.17 through 202.0.75.20.

The following entries configure the adapter correctly for this arrangement:

ifconfig_fxp0="inet 10.1.1.1 netmask 255.255.255.0"
ifconfig_fxp0_alias0="inet 10.1.1.2 netmask 255.255.255.255"
ifconfig_fxp0_alias1="inet 10.1.1.3 netmask 255.255.255.255"
ifconfig_fxp0_alias2="inet 10.1.1.4 netmask 255.255.255.255"
ifconfig_fxp0_alias3="inet 10.1.1.5 netmask 255.255.255.255"
ifconfig_fxp0_alias4="inet 202.0.75.17 netmask 255.255.255.240"
ifconfig_fxp0_alias5="inet 202.0.75.18 netmask 255.255.255.255"
ifconfig_fxp0_alias6="inet 202.0.75.19 netmask 255.255.255.255"
ifconfig_fxp0_alias7="inet 202.0.75.20 netmask 255.255.255.255"


--------------------------------------------------------------------------------
 楼主| 发表于 2003-12-17 10:23:50 | 显示全部楼层
第一个的IP地址为 192.168.1.25 netmask 255.255.255.0
broadcast 192.168.1.255

我增加一个IP地址,命令为

ifconfig lnc0 alias 192.168.1.88 netmask 255.255.255.255
后.查看的时候发现192.168.1.88的广播地址也是192.168.1.88 ,而不是
192.168.1.255 .我这两个地址是一个Subnet,192.168.1.88的广播地址也
应该是 192.168.1.255啊? (lnc0为我的网卡名称)
请问是怎么回事.
如果要把同一个Subnet的两个IP地址绑到一块网卡上应该用什么命令.
谢谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表