一台主机虚拟多个ip

拷贝一份eth0的配置文件为eth0:0在去修改一个DEVICE=eth0:0
下面的就按需分配了!
保存后用ifup eth0:0就可以启动了!
这样就可以给一块网卡配两个IP地址了!
多个ip就拷贝多份

点击(此处)折叠或打开

  1. [rootgc1:/root]$ more /etc/sysconfig/network-scripts/ifcfg-eth0
  2. ifcfg-eth0 ifcfg-eth0:0 ifcfg-eth0:1

点击(此处)折叠或打开

  1. [rootgc1:/root]$ more /etc/sysconfig/network-scripts/ifcfg-eth0
  2. # Please read /usr/share/doc/initscripts-*/sysconfig.txt
  3. # for the documentation of these parameters.
  4. TYPE=Ethernet
  5. DEVICE=eth0
  6. HWADDR=08:00:27:70:78:0e
  7. BOOTPROTO=none
  8. ONBOOT=yes
  9. USERCTL=no
  10. IPV6INIT=no
  11. PEERDNS=yes
  12. NETMASK=255.255.255.0
  13. IPADDR=192.168.6.114
  14. GATEWAY=192.168.6.1

点击(此处)折叠或打开

  1. [rootgc1:/root]$ more /etc/sysconfig/network-scripts/ifcfg-eth0:0
  2. # Please read /usr/share/doc/initscripts-*/sysconfig.txt
  3. # for the documentation of these parameters.
  4. TYPE=Ethernet
  5. DEVICE=eth0:0
  6. BOOTPROTO=none
  7. USERCTL=no
  8. IPV6INIT=no
  9. PEERDNS=yes
  10. NETMASK=255.255.255.0
  11. IPADDR=192.168.6.104
  12. GATEWAY=192.168.6.1
  13. ONPARENT=yes

方法二:直接在eth0 ip下面加一个也可以
方法三:图形化界面


方法四:(service network restart重启网卡会失效,还是得加到/etc/sysconfig/network-scripts/下去,,所以还是用前几种方法吧!)

  1. [root@gc2 ~]# ip address add 10.0.0.119/24 broadcast + dev eth0 label eth0:vbird
  2. [root@gc2 ~]# ifconfig
  3. eth0 Link encap:Ethernet HWaddr 08:00:27:76:7C:C9
  4.           inet addr:10.0.0.120 Bcast:10.0.0.255 Mask:255.255.255.0
  5.           inet6 addr: fe80::a00:27ff:fe76:7cc9/64 Scope:Link
  6.           UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
  7.           RX packets:1127213 errors:0 dropped:0 overruns:0 frame:0
  8.           TX packets:607063 errors:0 dropped:0 overruns:0 carrier:0
  9.           collisions:0 txqueuelen:1000
  10.           RX bytes:1551136168 (1.4 GiB) TX bytes:72197038 (68.8 MiB)
  11.           Base address:0xd010 Memory:f0000000-f0020000

  12. eth0:vbird Link encap:Ethernet HWaddr 08:00:27:76:7C:C9
  13.           inet addr:10.0.0.119 Bcast:10.0.0.255 Mask:255.255.255.0
  14.           UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
  15.           Base address:0xd010 Memory:f0000000-f0020000

  16. lo Link encap:Local Loopback
  17.           inet addr:127.0.0.1 Mask:255.0.0.0
  18.           inet6 addr: ::1/128 Scope:Host
  19.           UP LOOPBACK RUNNING MTU:16436 Metric:1
  20.           RX packets:43346 errors:0 dropped:0 overruns:0 frame:0
  21.           TX packets:43346 errors:0 dropped:0 overruns:0 carrier:0
  22.           collisions:0 txqueuelen:0
  23.           RX bytes:10650402 (10.1 MiB) TX bytes:10650402 (10.1 MiB)

  24. [root@gc2 ~]# ip address del 10.0.0.119/24 dev eth0
  25. [root@gc2 ~]# ifconfig
  26. eth0 Link encap:Ethernet HWaddr 08:00:27:76:7C:C9
  27.           inet addr:10.0.0.120 Bcast:10.0.0.255 Mask:255.255.255.0
  28.           inet6 addr: fe80::a00:27ff:fe76:7cc9/64 Scope:Link
  29.           UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
  30.           RX packets:1127213 errors:0 dropped:0 overruns:0 frame:0
  31.           TX packets:607064 errors:0 dropped:0 overruns:0 carrier:0
  32.           collisions:0 txqueuelen:1000
  33.           RX bytes:1551136168 (1.4 GiB) TX bytes:72197160 (68.8 MiB)
  34.           Base address:0xd010 Memory:f0000000-f0020000

  35. lo Link encap:Local Loopback
  36.           inet addr:127.0.0.1 Mask:255.0.0.0
  37.           inet6 addr: ::1/128 Scope:Host
  38.           UP LOOPBACK RUNNING MTU:16436 Metric:1
  39.           RX packets:43348 errors:0 dropped:0 overruns:0 frame:0
  40.           TX packets:43348 errors:0 dropped:0 overruns:0 carrier:0
  41.           collisions:0 txqueuelen:0
  42.           RX bytes:10650502 (10.1 MiB) TX bytes:10650502 (10.1 MiB)

或者
[root@node2 ~]# ifconfig eth0:0 192.168.8.111 netmask 255.255.255.0 up


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29096438/viewspace-1768193/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29096438/viewspace-1768193/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值