• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

为网卡配置多IP

发布: 2007-7-04 12:06 | 作者: admin | 来源:  网友评论 | 查看: 29次 | 进入软件测试论坛讨论

领测软件测试网 我用的是8139的网卡,今天为其配置了多个IP,这是我的配置经过……

为一块网卡配置多IP可以通过命令行设置也可以通过配置文件设置,以下我分别通过这两种方式实现:

1.用命令行设置
ifconfig命令格式:ifconfig 设备名 IP netmask 掩码 broadcast 广播地址 动作

[root@localhost root]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0E:1F:01:6C:50
          inet addr:192.168.16.108  Bcast:192.168.16.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:224 (224.0 b)  TX bytes:387 (387.0 b)
          Interrupt:11 Base address:0x2000
 
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:773 errors:0 dropped:0 overruns:0 frame:0
          TX packets:773 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:52352 (51.1 Kb)  TX bytes:52352 (51.1 Kb)
 
可以看到,当前eth0的IP为192.168.16.108,此时请注意一下MAC(00:0E:1F:01:6C:50)

现在我们为eth0绑定另一个IP,设备为eth0:0,可以看到,现在又多了一个IP,注意,网卡实际上只有一块(可以看MAC,都为00:0E:1F:01:6C:50),却绑定了两个IP,可以依此配置多个IP。
[root@localhost network-scripts]# ifconfig eth0:0 192.168.1.100 netmask 255.255.255.0
[root@localhost root]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0E:1F:01:6C:50
          inet addr:192.168.16.108  Bcast:192.168.16.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:29 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:2879 (2.8 Kb)  TX bytes:387 (387.0 b)
          Interrupt:11 Base address:0x2000
 
eth0:0    Link encap:Ethernet  HWaddr 00:0E:1F:01:6C:50
          inet addr:192.168.1.100  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:29 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:2879 (2.8 Kb)  TX bytes:387 (387.0 b)
          Interrupt:11 Base address:0x2000
 
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:7329 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7329 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:500674 (488.9 Kb)  TX bytes:500674 (488.9 Kb)

2.通过配置文件设置多IP
网卡IP配置的文件在/etc/sysconfig/network-scripts/下,文件分别为ehtx或ethx:x
[root@localhost root]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# ls
ifcfg-eth0      ifdown-ippp  ifdown-ppp  ifup-aliases  ifup-isdn   ifup-ppp     ifup-wireless
ifcfg-lo        ifdown-ipv6  ifdown-sit  ifup-ippp     ifup-plip   ifup-routes  init.ipv6-global
ifdown          ifdown-isdn  ifdown-sl   ifup-ipv6     ifup-plusb  ifup-sit     network-functions
ifdown-aliases  ifdown-post  ifup        ifup-ipx      ifup-post   ifup-sl      network-functions-ipv6
#这是eth0的对应的内容
[root@localhost network-scripts]#vi ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
PEERDNS=yes
TYPE=Ethernet
IPADDR=192.168.16.108
NETMASK=255.255.255.0
HWADDR=00:0e:1f:01:6c:50
GATEWAY=192.168.16.1
NETWORK=192.168.16.0
BROADCAST=192.168.16.255

配置另一IP,因我们刚才已配置了eth0:0,所以此时要用eth0:1了
[root@localhost network-scripts]# cp ifcfg-eth0 ifcfg-eth0:1
修改配置文件,内容如下
[root@localhost network-scripts]# vi ifcfg-eth0:1
DEVICE=eth0:1
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.2.100
NETMASK=255.255.255.0
NETWORK=192.168.2.0
启动eth0:1,查看,此时是不是就已经有三个IP了?
[root@localhost network-scripts]# ifup eth0:1
[root@localhost network-scripts]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0E:1F:01:6C:50
          inet addr:192.168.16.108  Bcast:192.168.16.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:52 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:6037 (5.8 Kb)  TX bytes:627 (627.0 b)
          Interrupt:11 Base address:0x2000
 
eth0:0    Link encap:Ethernet  HWaddr 00:0E:1F:01:6C:50
          inet addr:192.168.1.100  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:52 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:6037 (5.8 Kb)  TX bytes:627 (627.0 b)
          Interrupt:11 Base address:0x2000
 
eth0:1    Link encap:Ethernet  HWaddr 00:0E:1F:01:6C:50
          inet addr:192.168.2.100  Bcast:192.168.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:52 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:6037 (5.8 Kb)  TX bytes:627 (627.0 b)
          Interrupt:11 Base address:0x2000
 
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:14131 errors:0 dropped:0 overruns:0 frame:0
          TX packets:14131 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:965895 (943.2 Kb)  TX bytes:965895 (943.2 Kb)

OK,配置成功,这个随便你用哪种方法都可以,用配置文件的方法可以写一些注释,而用ifconfig则简单方便,这就看你的爱好了。 

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备2023014753号-2
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网