- 论坛徽章:
- 0
|
How can I bind multiple (virtual) IP addresses to a single network interface card ?
The following steps demonstrate how to configure the ethernet (elx0) device to support more than one IP address. 我的实验是基于X86平台完成的,这里创建的是/etc/hostname.pcn0:1,后面出现的也要做相应的更改。
Create a text file in the /etc directory called hostname.elx0:1 and add this entry to file:
virtual
Add this IP address and hostname in the /etc/hosts file:
10.0.0.1 virtual
Create a new script file in the /etc/rc2.d directory called S70virtual, and add these entries in this file (for permanent change):
ifconfig elx0:1 10.0.0.1 up netmask 255.255.255.0
Reboot the system.
To delete a logical interface, use the unplumb command . For example,
example% ifconfig elx0:1 down unplumb will delete the logical interface elx0:1.
bash-3.00# ifconfig -a
lo0: flags=2001000849 mtu 8232 index
1
inet 127.0.0.1 netmask ff000000
pcn0: flags=1004843 mtu 1500 index 2
inet 192.168.0.30 netmask ffffff00 broadcast 192.168.0.255
ether 0:c:29:d3:fc:eb
pcn0:1: flags=1000843 mtu 1500 index 2
inet 192.168.0.222 netmask ffffff00 broadcast 192.168.0.255
今日补充
看过SA-299后才知道,有一个更为简便的方法添加多块虚拟网卡:
bash-3.00# ifconfig pcn0 addif 192.168.0.222 netmask 255.255.255.0
提示已经添加网卡pcn0:1 (不指定netmask也可以,则会使用默认的。)
bash-3.00# ifconfig pcn0:1 up (必须执行此步骤,否则不会生效)
按些方法,你可以快速地添加第二块虚拟网卡,依此类推,该网卡命名方式为pcn0:2
以上方法是临时添加虚拟网卡的好方法,大家不妨一试。
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/26090/showart_315834.html |
|