Centos7.x 配置sub-interface (用於docker macvlan)

本文源於測試用sub-interface實現多macvlan網絡的實驗:
現有兩臺虛擬機:
host1:10.254.254.223
host2:10.254.254.224

以下操作在host1和host2上基本相同

1.配置多個sub-interface
首先開啓網卡的promisc模式

ip  link  set  ens33 promisc  on

然後

cp ifcfg-ens33 ifcfg-ens33.10
cp ifcfg-ens33 ifcfg-ens33.20

分別修改ifcfg-ens33.10和ifcfg-ens33.20的配置,設置不同網段的ip

PHYSDEV=ens33(host網卡)
VLAN=yes
TYPE=Vlan
VLAN_ID=10(vlan的id)
REORDER_HDR=yes
GVRP=no
MVRP=no
BOOTPROTO=none
IPADDR=172.16.10.10(sub-interface的ip)
PREFIX=24
GATEWAY=172.16.10.1(sub-interface的網關)
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
NAME=ens33.10(sub-interface名)
ONBOOT=yes
 

PHYSDEV=ens33(host網卡)
VLAN=yes
TYPE=Vlan
VLAN_ID=20(vlan的id)
REORDER_HDR=yes
GVRP=no
MVRP=no
BOOTPROTO=none
IPADDR=172.16.20.10(sub-interface的ip)
PREFIX=24
GATEWAY=172.16.20.1(sub-interface的網關)
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
NAME=ens33.20(sub-interface名)
ONBOOT=yes

重啓網卡,使配置生效

systemctl  restart  network

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章