关闭

linux双网卡配置

别叨叨 1年前 ⋅ 175 阅读

首先查看机器是否是双网卡:

lspci | grep -i ether

配置步骤:

  1. 修改network:
    vi /etc/sysconfig/network​
    NETWORKING=yes
    HOSTNAME=thingsboard	
    GATEWAY=192.168.10.1  	#外网网关​
  2. 第一个网卡配置:
    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
  3. 第二个网卡配置:
    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
  4. 路由设置:
    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​

全部评论: 0

    我有话说: