查看网卡:
ip addr
网卡配置目录:
/etc/sysconfig/network-scripts
添加配置文件 文件名 ifcfg-eth0 ifcfg-eth0:1 ifcfg-eth1 ifcfg-eth1:1 HWADDR是网卡的mac 注意配置错误会导致网络不能访问
BOOTPROTO=static
DEVICE=eth0
HWADDR=52:54:00:86:02:e4
NM_CONTROLLED=no
ONBOOT=yes
PERSISTENT_DHCLIENT=yes
TYPE=Ethernet
USERCTL=no
IPADDR=192.168.0.12
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
修改配置 输入 i 修改 esc :wq 保存退出
解决多网卡多公网不能同时访问
vim /etc/sysctl.conf
把配置文件中原配置中的net.ipv4.conf.default.rp_filter = 1,修改成:
net.ipv4.conf.default.rp_filter = 0 net.ipv4.conf.all.rp_filter = 0 net.ipv4.conf.eth0.rp_filter = 0 net.ipv4.conf.eth1.rp_filter = 0
重启
systemctl restart network ``` 参考: 1.https://cloud.tencent.com/document/product/576/18535 2.https://qsh5.cn/757.html 3.https://www.vdazhang.com/wenzhang-1946.html