免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1138 | 回复: 0
打印 上一主题 下一主题

单网卡绑定多IP [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-06-06 12:15 |只看该作者 |倒序浏览
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
  • 您需要登录后才可以回帖 登录 | 注册

    本版积分规则 发表回复

      

    北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
    未成年举报专区
    中国互联网协会会员  联系我们:huangweiwei@itpub.net
    感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

    清除 Cookies - ChinaUnix - Archiver - WAP - TOP