首先查看机器是否是双网卡:
lspci | grep -i ether
配置步骤:
- 修改network:
vi /etc/sysconfig/network
NETWORKING=yes HOSTNAME=thingsboard GATEWAY=192.168.10.1 #外网网关
- 第一个网卡配置:
cat /etc/sysconfig/network-scripts/ifcfg-em1
UID=b42b61a7-0a88-4809-b596-b13bf802b813 TYPE="Ethernet" BOOTPROTO="static" DEVICE="em1" ONBOOT="yes" HWADDR=d0:94:66:80:f0:3c IPADDR=192.168.10.100 NETMASK=255.255.255.0 GATEWAY=192.168.10.1 DNS1=211.137.186.224 DNS2=8.8.8.8
- 第二个网卡配置:
cat /etc/sysconfig/network-scripts/ifcfg-em2
UUID=92327720-60de-4603-a77b-2a84459f0198 TYPE="Ethernet" BOOTPROTO="static" DEVICE="em2" ONBOOT="yes" IPADDR=192.168.1.189 NETMASK=255.255.255.0
- 路由设置:
ip route flush table table1 ip route add default via 192.168.1.1 dev em1 src 192.168.1.100 table table1 ip rule add from 192.168.1.100 table table1 ip route flush table table2 ip route add default via 192.168.1.1 dev em2 src 192.168.1.253 table table2 ip rule add from 192.168.1.253 table table2
注意:本文归作者所有,未经作者允许,不得转载