centos 服务器 多网卡 ip 地址 设置
https://blog.csdn.net/xh_w20/article/details/141574357
cd /etc/sysconfig/network-scripts/
sudo systemctl status network
● network.service - LSB: Bring up/down networking
Loaded: loaded (/etc/rc.d/init.d/network; bad; vendor preset: disabled)
Active: active (exited) since Mon 2024-09-09 14:05:44 CST; 52s ago
Docs: man:systemd-sysv-generator(8)
Process: 935 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=0/SUCCESS)
Sep 09 14:05:42 localhost.localdomain systemd[1]: Starting LSB: Bring up/down networking...
Sep 09 14:05:43 localhost.localdomain network[935]: Bringing up loopback interface: [ OK ]
Sep 09 14:05:44 localhost.localdomain network[935]: Bringing up interface enp3s0: Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2)
Sep 09 14:05:44 localhost.localdomain network[935]: [ OK ]
Sep 09 14:05:44 localhost.localdomain network[935]: Bringing up interface enp4s0: [ OK ]
Sep 09 14:05:44 localhost.localdomain systemd[1]: Started LSB: Bring up/down networking.
ifconfig
enp3s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.99.166 netmask 255.255.255.0 broadcast 192.168.99.255
inet6 fe80::6245:2ae4:d24:2be5 prefixlen 64 scopeid 0x20<link>
ether 00:e0:b4:1d:88:1c txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0xd0700000-d071ffff
enp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.99.165 netmask 255.255.255.0 broadcast 192.168.99.255
inet6 fe80::1920:9a3d:e274:a7a8 prefixlen 64 scopeid 0x20<link>
ether 00:e0:b4:1d:88:1d txqueuelen 1000 (Ethernet)
RX packets 585 bytes 72467 (70.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 167 bytes 19609 (19.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0xd0600000-d061ffff
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 1000 (Local Loopback)
RX packets 68 bytes 5916 (5.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 68 bytes 5916 (5.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
cat bak_ifcfg-enp3s0
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp3s0
UUID=c215c68d-3667-4e8a-b7a1-1835e21212ee
DEVICE=enp3s0
ONBOOT=no
cat ifcfg-enp4s0
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="enp4s0"
UUID="a44b095c-4cc9-4963-8c89-24f256537e64"
DEVICE="enp4s0"
ONBOOT="yes"
IPADDR="192.168.99.165"
PREFIX="24"
GATEWAY="192.168.99.1"
DNS1="192.168.99.1"
DNS2="8.8.8.8"
IPV6_PRIVACY="no"
如果 enp3s0 不插网线 , enp4s0 插入网线, 两者同时设置为 192.168.99.165 会出现问题。
route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.99.1 0.0.0.0 UG 100 0 0 enp4s0
0.0.0.0 192.168.99.1 0.0.0.0 UG 101 0 0 enp3s0
192.168.99.0 0.0.0.0 255.255.255.0 U 100 0 0 enp4s0
192.168.99.0 0.0.0.0 255.255.255.0 U 101 0 0 enp3s0
111
DEFROUTE这个变量没定义
default route
DEFROUTE=yes