Centos单网卡配置多IP

前端之家收集整理的这篇文章主要介绍了Centos单网卡配置多IP前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1、复制eth0网卡配置文件

$ cd /etc/sysconfig/network-scripts/
$ cp ifcfg-eth0 ifcfg-eth0:0
$ vim ifcfg-etg0:0
DEVICE=eth0:0  #修改为eth0:0
HWADDR=00:0c:29:e4:19:b3  #网卡MAC地址要保持和eth0一致
TYPE=Ethernet
UUID=54dff50b-0795-4f35-87a2-e4f0ec3e345e
ONBOOT=yes  #开机启动
ARPCHECK=no
BOOTPROTO=static
IPADDR=192.168.1.11  #修改ip
NETMASK=255.255.252.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8

2、启动eth0:0

$ ifup eth0:0
启动eth0:0
注:不用重启网卡

3、检查是否生效

主要是两个命令ifconfigip addr可以看到配置好的新ip即可,外部也可以ping一下看是否能通。

$ ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:E4:19:B3  
          inet addr:192.168.1.10  Bcast:192.168.1.255  Mask:255.255.252.0
          inet6 addr: fe80::20c:29ff:fee4:19b3/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:99256 errors:0 dropped:0 overruns:0 frame:0
          TX packets:95314 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:13795190 (13.1 MiB)  TX bytes:10841617 (10.3 MiB)

eth0:0    Link encap:Ethernet  HWaddr 00:0C:29:E4:19:B3  
          inet addr:192.168.1.11  Bcast:192.168.1.255  Mask:255.255.252.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

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:11 errors:0 dropped:0 overruns:0 frame:0
          TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:660 (660.0 b)  TX bytes:660 (660.0 b)
          
$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:e4:19:b3 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.10/24 brd 192.168.1.255 scope global eth0
    inet 192.168.1.11/24 brd 192.168.1.255 scope global secondary eth0:0
    inet6 fe80::20c:29ff:fee4:19b3/64 scope link 
       valid_lft forever preferred_lft forever

猜你在找的CentOS相关文章