운영체제/Unix & Linux
[Linux] 802.1q VLAN Tagging 설정
날았다 고양이
2019. 12. 10. 10:53
반응형
개요
구성환경
CentOS 7.6
구성
사전 작업
모듈 적재 확인(디폴트로 8021q 모듈이 적재되어 있음)
shell> lsmod | grep 8021q
[root@testsvr network-scripts]# lsmod | grep 8021q 8021q 33208 0 garp 14384 1 8021q mrp 18542 1 8021q [root@testsvr network-scripts]# |
만약 모듈이 적재 되어 있이 않을 경우 아래 명령어로 모듈 적재
shell> modprobe 8021q
설정 1) ifcfg 파일(부팅시 적용)
파일네이밍 : ifcfg-인터페이스명.VLANID
ifcfg 파일 위치 : /etc/sysconfig/network-scripts 디렉토리
예) ifcfg-ens32.20
DEVICE=ens32.20 IPADDR="192.168.20.167" PREFIX="24" VLAN="yes" |
ifcfg 파일을 수정한 후에는 네트워크 서비스 재시작
shell> systemctl restart network
** 네트워크 서비스가 실패할 경우 NetworkManager 서비스 중지
shell> systemctl stop NetworkManager
or shell> systemctl disable NetworkManager
설정 2) CLI 이용(부팅시 적용 안됨)
인터페이스에 VLAN ID 할당
shell> ip link add link ens32 name ens32.20 type vlan id 20
인터페이서에 IP 할당
shell> ifconfig ens32.20 192.168.20.167 netmask 255.255.255.0
[root@testsvr network-scripts]# ip link add link ens32 name ens32.20 type vlan id 20 [root@testsvr network-scripts]# ifconfig ens32.20 ens32.20: flags=4098<BROADCAST,MULTICAST> mtu 1500 ether 00:0c:29:ca:d7:09 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@testsvr network-scripts]# ifconfig ens32.20 192.168.20.167 netmask 255.255.255.0 [root@testsvr network-scripts]# ifconfig ens32.20 ens32.20: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.20.167 netmask 255.255.255.0 broadcast 192.168.20.255 inet6 fe80::20c:29ff:feca:d709 prefixlen 64 scopeid 0x20 ether 00:0c:29:ca:d7:09 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 23 bytes 3661 (3.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@testsvr network-scripts]# |
인터페이스 삭제
shell> ip link delete ens32.20
shell> rm /etc/sysconfig/network-scripts/ifcfg-ens32.20
인터페이스 모니터링
확인 1)
shell> ip -d link show ens32.20
[root@testsvr network-scripts]# ip -d link show ens32.20 7: ens32.20@ens32: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 00:0c:29:ca:d7:09 brd ff:ff:ff:ff:ff:ff promiscuity 0 vlan protocol 802.1Q id 20 addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 [root@testsvr network-scripts]# |
확인 2)
[root@testsvr network-scripts]# cat /proc/net/vlan/ens32.20 ens32.20 VID: 20 REORDER_HDR: 1 dev->priv_flags: 1 total frames received 0 total bytes received 0 Broadcast/Multicast Rcvd 0 total frames transmitted 0 total bytes transmitted 0 Device: ens32 INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 EGRESS priority mappings: [root@testsvr network-scripts]# |
반응형