使⽤IP和vconfig配置vlan⼦接⼝
⼀、使⽤IP命令配置
此前ArchLinux⽤vconfig命令设置VLANs,该命令已被ip命令取代。下⾯的范例假定⽹⼝⽹⼝是enp125s0f0,名名
字是enp125s0f0.100,vlanidvlanid是100。
1.创建VLAN设备
⽤下列命令添加VLAN⽹⼝:
#iplinkaddlinkenp125s0f0nameenp125s0f0.100typevlanid100
执⾏iplink命令确认VLAN已创建。
这个VLAN⽹⼝就像⼀个普通的物理⽹⼝,所有流经这个⽹⼝的数据包将被加上VLANtag并流经它关联的物理⽹⼝(本例中
的enp125s0f0)。仅配置为相同VLAN的设备可接收这些数据包,否则将被丢弃。
Usinganamenamelikeenp125s0f0.100isjustconventionandnotenforced;youcanalternativelyuenp125s0f0_100or
heVLANIDonaninterface,incayouudanunconventionalname:
#ip-dlinkshowenp125s0f0.100
The-dflagshowsfulldetailsonaninterface:
#ip-dlinkshowenp125s0f0.100
7:enp125s0f0.100@enp125s0f0:
DEFAULTgroupdefaultqlen1000
link/ether8c:e5:ef:97:50:c8brdff:ff:ff:ff:ff:ffpromiscuity0minmtu0maxmtu65535
vlanprotocol802.1不再见简谱
Qid100
gso_max_size65536gso_max_gs65535
2.添加IP
NowaddanIPv4addresstothejustcreatedvlanlink,andactivat落款怎么写 ethelink:
#ipaddradd192.168.100.1/24brd192.168.100.255devenp125s0f0.100
#iplinktdevenp125s0f0.100up
3.关闭设备
Tocleanlyshutdownthettingbeforeyouremovethelink,youcando:
#iplinktdevenp125s0f0.100down
4.移除设备
RemovingaVLANinterfaceissignificantlylessconvoluted
#iplinkdeleteenp125s0f0.100
⼆、使⽤vconfig配置
1.安装vlan(vconfig)和加载8021q模块
#aptitudeinstallvlan
#modprobe8021q
或:
#yuminstallvconfig
#modprobe8021q
#lsmod|grep-i8021q
2.使⽤linuxvconfig命令配置vlan
#vconfigaddenp8s0f1100
#vconfigaddenp8s0f1200
在enp8s0f1接⼝上配置两个VLAN
#vco薄荷糖的功效与作用 nfigt_flagenp8s0f1腐竹凉菜 .10011
#vconfigt_flagenp8s0f1.20011
设置VLAN的REORDER_HDR参数,默认就⾏了。
可以使⽤cat/proc/net/vlan/enp8s0f1.100查看enp8s0f1.100参数
配置⽹络信息
#ifco朱槿牡丹 nfigenp8s0f10.0.0.0
#ifconfigenp8s0f1.100192.168.100.50netmask255.255.255.0up
#ifconfigenp8s0f1.200192.168.200.50netmask255.255.255.0up
删除VLAN命令
#vconfigremenp8s0f1.100
#vconfigremenp8s0f1.200
3.将VLAN信息写⼊配置⽂件
#echo"modprobe8021q">>/etc/
开机加载8021q模块,或者使⽤
echo"8021q">>/etc/modules
#cp/etc/network/interfaces/etc/network/t
#vim/etc/network/interfaces
autoloenp8s0f1
ifaceloinetloopback
ifaceenp8s0f1.100inetstatic
address192.168.100.50
netmask255.255.255.0
ifaceenp8s0f1.200inetstatic
address192.168.200.50
netmask255贫贱 .255.255.0
本文发布于:2023-03-22 20:25:45,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/1679487948346182.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:子接口.doc
本文 PDF 下载地址:子接口.pdf
留言与评论(共有 0 条评论) |