单网卡、双ip
指尖二进制 • 1 年前 • 759 次点击 • LINUX
查看当前系统的ip地址和网卡的设备名
[root@bogon network-scripts]# ifconfig
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.180 netmask 255.255.254.0 broadcast 192.168.1.255
inet6 fe80::20c:29ff:fe2a:1994 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:2a:19:94 txqueuelen 1000 (Ethernet)
RX packets 12436 bytes 14219464 (13.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 5424 bytes 493467 (481.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 1 bytes 152 (152.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1 bytes 152 (152.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eno16777736网卡在原有基础之上,再去添加一个ip地址。
修改配置文件ifcfg-eno16777736:1
[root@bogon network-scripts]# cat ifcfg-eno16777736:1
DEVICE=eno16777736:1
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.111.101
NETMASK=255.255.255.0
GATEWAY=192.168.111.1
重启设备
/etc/init.d/network restart
查看两个地址
[root@bogon network-scripts]# ifconfig
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.180 netmask 255.255.254.0 broadcast 192.168.1.255
inet6 fe80::20c:29ff:fe2a:1994 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:2a:19:94 txqueuelen 1000 (Ethernet)
RX packets 13271 bytes 14288552 (13.6 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 5502 bytes 502967 (491.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eno16777736:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.111.101 netmask 255.255.255.0 broadcast 192.168.111.255
ether 00:0c:29:2a:19:94 txqueuelen 1000 (Ethernet)
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 1 bytes 152 (152.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1 bytes 152 (152.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
测试,192.168.111.1一直ping 192.168.111.101 和192.168.1.180。
在192.168.1.180服务器ifdown eno16777736