免费注册 查看新帖 |

Chinaunix

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

如何在一块网卡绑定多个ip [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-04-05 11:56 |只看该作者 |倒序浏览
需求:linux as 4.2系统下实现一个网卡可以网管多个ip段的设备(多个ip段都在同一个vlan中)
分析:实现这个需要在一块网卡上面绑定多个网段的ip
解决:
1、增加一个虚拟的网卡文件
cd /etc/sysconfig/network-scripts/
cp ifcfg-eth1 ifcfg-eth1:0
2、编辑eth1:0,改变其中的ip地址、设备名称等信息
vi ifcfg-eth1:0
# Broadcom Corporation NetXtreme BCM5721 Gigabit Ethernet PCI Express
DEVICE=eth1:0 #这里更改为新的虚拟设备名称
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.x.250 #这里更改为新网段的ip
NETMASK=255.255.255.0
HWADDR=00:17:x.x:B1:C1 #这里不能更改
然后保存ifcfg-eth1:0文件
3、重启网络服务
[root@xxxx network-scripts]# service network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down interface eth1:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Setting network parameters:                                [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:                                [  OK  ]
Bringing up interface eth1:                                [  OK  ]
4、测试
[root@xxxx network-scripts]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.x.x.0    *               255.255.255.0   U     0      0        0 eth1
172.x.x.0     *               255.255.255.0   U     0      0        0 eth0
192.168.x.0   *               255.255.255.0   U     0      0        0 eth1
default         172.x.x.1     0.0.0.0         UG    0      0        0 eth0
[root@xxxx network-scripts]# ping 10.x.x.250
PING 10.254.254.250 (10.254.254.250) 56(84) bytes of data.
64 bytes from 10.x.x.250: icmp_seq=0 ttl=64 time=0.023 ms
64 bytes from 10.x.x.250: icmp_seq=1 ttl=64 time=0.013 ms
--- 10.254.254.250 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.013/0.018/0.023/0.005 ms, pipe 2
[root@xxxx network-scripts]# ping 192.168.x.7
PING 192.168.x.7 (192.168.200.7) 56(84) bytes of data.
64 bytes from 192.168.x.7: icmp_seq=0 ttl=30 time=2.67 ms
64 bytes from 192.168.x.7: icmp_seq=1 ttl=30 time=0.680 ms
--- 192.168.200.7 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.680/1.675/2.670/0.995 ms, pipe 2
[root@xxxx network-scripts]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:18:FE:79:31:E3  
          inet addr:172.x.x.2  Bcast:172.x.x.255  Mask:255.255.255.0
          inet6 addr: fe80::218:feff:fe79:31e3/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:165 errors:0 dropped:0 overruns:0 frame:0
          TX packets:142 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:14086 (13.7 KiB)  TX bytes:21278 (20.7 KiB)
          Interrupt:177
eth1      Link encap:Ethernet  HWaddr 00:17:08:56:B1:C1  
          inet addr:10.x.x.250  Bcast:10.x.x.255  Mask:255.255.255.0
          inet6 addr: fe80::217:8ff:fe56:b1c1/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:351 errors:0 dropped:0 overruns:0 frame:0
          TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:27333 (26.6 KiB)  TX bytes:1190 (1.1 KiB)
          Interrupt:169
eth1:0    Link encap:Ethernet  HWaddr 00:17:08:56:B1:C1  
          inet addr:192.168.x.250  Bcast:192.168.x.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:169


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/22266/showart_271402.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP