在windows下给一块网卡设置多个IP,是比较容易的,今天我写的内容是关于在LINUX系统下,给一块网卡设置多个IP地址,在Linux系统下面,第一块网卡就叫eth0,第二块网卡就叫eth1,这里我们给第一块网卡设置多个IP,在Linux下,配置网卡的配置文件在目录/etc/sysconfig/network-script/下 ,原来网卡的配置文件名为ifcfg-eth0 ,我们给一块网卡配置多个IP地址的配置文件命名为ifcfg-eth0:1和ifcfg-eth0 :2,下面看操作如下:

Last login: Fri Aug  6 00:35:49 2010 from 172.28.102.41
[root@rep1 ~]# ifconfig                             ###原来网卡的配置
eth0      Link encap:Ethernet  HWaddr 00:0C:29:D5:39:A0 
          inet addr:172.28.90.101  Bcast:172.28.255.255  Mask:255.255.0.0
          inet6 addr: fe80::20c:29ff:fed5:39a0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3125184 errors:0 dropped:0 overruns:0 frame:0
          TX packets:101356 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:462342976 (440.9 MiB)  TX bytes:10788008 (10.2 MiB)
          Interrupt:75 Base address:0x2000
lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:1427 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1427 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:3335045 (3.1 MiB)  TX bytes:3335045 (3.1 MiB)
[root@rep1 ~]# cd /etc/sysconfig/net
netconsole       network          networking/      network-scripts/
[root@rep1 ~]# cd /etc/sysconfig/network-scripts/         #配置文件的目录路径
[root@rep1 network-scripts]# ls
ifcfg-eth0    ifdown-isdn    ifup-aliases  ifup-plip    ifup-wireless
ifcfg-lo      ifdown-post    ifup-bnep     ifup-plusb   init.ipv6-global
ifdown        ifdown-ppp     ifup-eth      ifup-post    net.hotplug
ifdown-bnep   ifdown-routes  ifup-ippp     ifup-ppp     network-functions
ifdown-eth    ifdown-sit     ifup-ipsec    ifup-routes  network-functions-ipv6
ifdown-ippp   ifdown-sl      ifup-ipv6     ifup-sit
ifdown-ipsec  ifdown-tunnel  ifup-ipx      ifup-sl
ifdown-ipv6   ifup           ifup-isdn     ifup-tunnel
[root@rep1 network-scripts]# cp ifcfg-eth0 ifcfg-eth0:1      #复制原来网卡配置
[root@rep1 network-scripts]# cp ifcfg-eth0 ifcfg-eth0:2     #复制原来网卡配置
[root@rep1 network-scripts]# vi ifcfg-eth0:1
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0:1                                        #此处修改
BOOTPROTO=static
BROADCAST=172.28.255.255              #IP地址的广播地址
HWADDR=00:0C:29:D5:39:A0             #MAC地址,不用修改
IPADDR=172.28.90.201                         #设置新的IP
NETMASK=255.255.0.0
NETWORK=172.28.0.0
ONBOOT=yes
~
——————————————————————————————————
~
"ifcfg-eth0:1" 9L, 206C written
[root@rep1 network-scripts]# vi ifcfg-eth0:2
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0:2                                                #此处修改
BOOTPROTO=static
BROADCAST=172.28.255.255                    #IP地址的广播地址
HWADDR=00:0C:29:D5:39:A0                    #MAC地址,不用修改
IPADDR=172.28.90.202                                 #设置新的IP
NETMASK=255.255.0.0
NETWORK=172.28.0.0
ONBOOT=yes
~
———————————————————————————————————
~
"ifcfg-eth0:2" 9L, 206C written
[root@rep1 network-scripts]# service network restart           #重启下网络服务
Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:                                [  OK  ]
[root@rep1 network-scripts]# ifconfig                             #修改好后验证是否成功
eth0      Link encap:Ethernet  HWaddr 00:0C:29:D5:39:A0 
          inet addr:172.28.90.101  Bcast:172.28.255.255  Mask:255.255.0.0
          inet6 addr: fe80::20c:29ff:fed5:39a0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3131096 errors:0 dropped:0 overruns:0 frame:0
          TX packets:101660 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:462925438 (441.4 MiB)  TX bytes:10829005 (10.3 MiB)
          Interrupt:75 Base address:0x2000
eth0:1    Link encap:Ethernet  HWaddr 00:0C:29:D5:39:A0 
          inet addr:172.28.90.201  Bcast:172.28.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:75 Base address:0x2000
eth0:2    Link encap:Ethernet  HWaddr 00:0C:29:D5:39:A0 
          inet addr:172.28.90.202  Bcast:172.28.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:75 Base address:0x2000
lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:1427 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1427 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:3335045 (3.1 MiB)  TX bytes:3335045 (3.1 MiB)
[root@rep1 network-scripts]# ls
ifcfg-eth0
    ifdown-ipsec   ifdown-tunnel  ifup-ipx     ifup-sl
ifcfg-eth0:1  ifdown-ipv6    ifup           ifup-isdn    ifup-tunnel
ifcfg-eth0:2  ifdown-isdn    ifup-aliases   ifup-plip    ifup-wireless
ifcfg-lo      ifdown-post    ifup-bnep      ifup-plusb   init.ipv6-global
ifdown        ifdown-ppp     ifup-eth       ifup-post    net.hotplug
ifdown-bnep   ifdown-routes  ifup-ippp      ifup-ppp     network-functions
ifdown-eth    ifdown-sit     ifup-ipsec     ifup-routes  network-functions-ipv6
ifdown-ippp   ifdown-sl      ifup-ipv6      ifup-sit
[root@rep1 network-scripts]#

我们再wind下验证下是否通。。。
C:\Documents and Settings\Administrator>ping 172.28.90.101
Pinging 172.28.90.101 with 32 bytes of data:
Reply from 172.28.90.101: bytes=32 time=17ms TTL=63
Reply from 172.28.90.101: bytes=32 time=14ms TTL=63
Ping statistics for 172.28.90.101:
    Packets: Sent = 2, Received = 2, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 14ms, Maximum = 17ms, Average = 15ms
Control-C
^C
C:\Documents and Settings\Administrator>ping 172.28.90.201
Pinging 172.28.90.201 with 32 bytes of data:
Reply from 172.28.90.201: bytes=32 time=38ms TTL=63
Reply from 172.28.90.201: bytes=32 time=18ms TTL=63
Reply from 172.28.90.201: bytes=32 time=2ms TTL=63
Ping statistics for 172.28.90.201:
    Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 2ms, Maximum = 38ms, Average = 19ms
Control-C
^C
C:\Documents and Settings\Administrator>ping 172.28.90.202
Pinging 172.28.90.202 with 32 bytes of data:
Reply from 172.28.90.202: bytes=32 time=39ms TTL=63
Reply from 172.28.90.202: bytes=32 time=17ms TTL=63
Reply from 172.28.90.202: bytes=32 time=17ms TTL=63

Linux下一块网卡设置多个IP地址相关推荐

  1. Linux设置一个网卡IP地址,linux下一块网卡设置多个ip地址(示例代码)

    无论是在实际的生产坏境中,还是平时的练习中, 一个网卡设置多个ip地址是非常常见的,也是非常有用的. 我们以centos6.8系统为列, 在一块网卡上设置多个ip地址. 1>. 给一块网卡设置多 ...

  2. 一块网卡设置多个IP地址

    linux下: 两种方法:     第一种     ifconfig eth0 192.168.1.1     ifconfig eth0:1 192.168.2.1     ifconfig eth ...

  3. 在windows xp下,一块网卡绑定多个ip

    通常在windows xp下,一块网卡只能绑定一个IP,这给我上网带来诸多不便.因为我在单位和在宿舍使用笔记本时,需要分别设置IP.Gateway.DNS,重新设置一个网络连接,前一天晚上在宿舍改好了 ...

  4. linux给网卡添加一个ip地址,linux网络配置中如何给一块网卡添加多个IP地址

    汤向峰每日一题-2017年3月16日: linux网络配置中如何给一块网卡添加多个IP地址 linux系统给网卡配置VIP的方法常见有两种:别名IP.以及辅助IP ================== ...

  5. linux配置指定ip访问指定端口号,操作系统linux和dos linux下通过iptables只允许指定ip地址访问指定端...

    一篇 : linux下通过iptables只允许指定ip地址访问指定端口的设置方法 首先,清除所有预设置 iptables -F#清除预设表filter中的所有规则链的规则 iptables -X#清 ...

  6. Linux下配置Apache虚拟主机(基于IP地址)

    Linux下配置Apache虚拟主机(基于IP地址) 一.虚拟主机 虚拟主机,又称虚拟服务器,是一种在单一主机或主机群上,实现多网域服务的方法,可以运行多个网站或服务的技术.虚拟主机之间完全独立,并可 ...

  7. Linux下 单网卡配置多个ip方法

    Linux下配置网卡ip别名何谓ip别名? 用windows的话说,就是为一个网卡配置多个ip. 什么场合增加ip别名能派上用场? 布网需要.多ip访问测试.特定软件对多ip的需要-and so on ...

  8. Linux下多网卡同网段多IP网络分流设定方法

    当服务器需要较高的网络流量时,在其它资源不造成瓶颈的情况下无疑会用到多网卡. 第1选项可考虑Linux的多网卡绑定,网上很多文章不推荐Linux服务器使用同网段的服务器,哥表示不解. 用过Window ...

  9. linux下 etho网卡设置

    1.首先,用 ifconfig 命令查询是否存在eth0网卡 2.vi /etc/sysconfig/network-scripts/ifcfg-eth0 编辑ifcfg-eth0文件,如图: 加上以 ...

最新文章

  1. 商汤联手华科:提出文字检测模型GNNets,新颖模块可解决几何分布难题
  2. 谁说GPT只擅长生成?清华研究力证:GPT语言理解能力不输BERT
  3. MySQL的存储引擎与日志说明
  4. allgro显示网络名称_相同的4G网络,为什么你的网速总是慢?知道这3点原因,网速翻倍...
  5. 谈谈mysql优化_浅谈MySQL SQL优化
  6. Python装饰器学习笔记 1
  7. 串口中断和定时器中断_启士 | 蓝桥杯单片机教程12 中断与定时器 (上)
  8. python实现信号幅值归一化
  9. 铵钮提交事件PostBack之后,一些动态加载的物件丢失
  10. 【E-DEEC】基于matlab增强的分布式能源有效集群(E-DEEC)【含Matlab源码 1566期】
  11. Mysql常用内置函数
  12. 程序员的SQL金典-杨中科
  13. SVN 客户端下载与安装
  14. 四、OSPF配置实验
  15. 兔子生兔子java_用Java编程计算兔子生兔子的问题
  16. 120550-35-8,Biotin-PFP ester生物素-五氟苯酯与伯氨基(-NH2)反应
  17. python爬虫爬取必应壁纸
  18. Java知识点笔记(一):how2j.cn的学习(一)
  19. Intellij IDEA摸鱼插件 看电子书 AndroidStudio 摸鱼插件 摸鱼神器 IdeaTxt
  20. arcade 物理系统_RetroPie和X-Arcade Tankstick-完美的Retro Arcade(加上键绑定,配置和操作方法)

热门文章

  1. 谷歌修复已遭利用的 0day
  2. 火眼公司发布公开漏洞奖励计划
  3. 从“No space left on device”到删除海量文件
  4. 万达9.3亿美元并购北欧最大院线 全球市场份额逼近20%
  5. 部署全局ajax处理
  6. [安卓] 18、一个简单的例子做自定义动画按钮和自定义Actionbar
  7. shell之任务控制
  8. KVM virtio bug整理
  9. 【指针】C++中指针的使用艺术[转]
  10. 6 important .NET concepts: - Stack, heap, Value types, reference types, boxing and Unboxing.