linux

centos - vlan 설정

sysman 2020. 12. 31. 20:18

vmware workstation-> vm세팅-> network-> segment 만들어서 할당 

서버1에서

태깅을 위해 모듈 등록
#lsmod | grep 8021q
#modinfo 8021q
#modprobe 8021q
#lsmode | grep 8021q

#vi ifcfg-ens37
[root@server1 network-scripts]# cat ifcfg-ens37
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens37
UUID=
DEVICE=ens37
ONBOOT=yes
IPV6_PRIVACY=no


#vi ifcfg-ens37.5
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens37.5
UUID=
DEVICE=ens37.5
ONBOOT=yes
IPADDR=192.168.37.5
NETMASK=255.255.255.0
VLAN=yes
IPV6_PRIVACY=no
NETWORK=192.168.37.0
[root@server1 network-scripts]#


#vi ifcfg-ens37.10
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens37.5
UUID=
DEVICE=ens37.5
ONBOOT=yes
IPADDR=192.168.37.5
NETMASK=255.255.255.0
VLAN=yes
IPV6_PRIVACY=no
NETWORK=192.168.37.0

#reboot


#ip a
3: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:32:72:72 brd ff:ff:ff:ff:ff:ff
4: ens37.5@ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:0c:29:32:72:72 brd ff:ff:ff:ff:ff:ff
    inet 192.168.37.5/24 brd 192.168.37.255 scope global noprefixroute ens37.5
       valid_lft forever preferred_lft forever
    inet6 fe80::a9d3:6f00:b128:fd87/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
5: ens37.10@ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:0c:29:32:72:72 brd ff:ff:ff:ff:ff:ff
    inet 192.168.100.1/24 brd 192.168.100.255 scope global noprefixroute ens37.10

vlan 생성확인
[root@server1 network-scripts]# cat /proc/net/vlan/ens37.5
ens37.5  VID: 5  REORDER_HDR: 1  dev->priv_flags: 1021
         total frames received            0
          total bytes received            0
      Broadcast/Multicast Rcvd            0

      total frames transmitted           13
       total bytes transmitted          938
Device: ens37
INGRESS priority mappings: 0:0  1:0  2:0  3:0  4:0  5:0  6:0 7:0
 EGRESS priority mappings:
[root@server1 network-scripts]# cat /proc/net/vlan/ens37.10
ens37.10  VID: 10        REORDER_HDR: 1  dev->priv_flags: 1021
         total frames received            0
          total bytes received            0
      Broadcast/Multicast Rcvd            0

      total frames transmitted           13
       total bytes transmitted          938
Device: ens37
INGRESS priority mappings: 0:0  1:0  2:0  3:0  4:0  5:0  6:0 7:0
 EGRESS priority mappings:
[root@server1 network-scripts]#

===================================

서버2에서
태깅을 위해 모듈 등록
#lsmod | grep 8021q
#modinfo 8021q
#modprobe 8021q
#lsmode | grep 8021q

#vi ifcfg-ens39
TYPE=Ethernet
BOOTPROTO=none
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_AUTOCONF=no
IPV6_DEFROUTE=no
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens37
DEVICE=ens37
ONBOOT=yes
IPV6_PRIVACY=no


#vi ifcfg-ens39.5
BOOTPROTO=none
IPV6INIT=no
IPV6_AUTOCONF=no
IPV6_DEFROUTE=no
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens39.5
DEVICE=ens39.5
ONBOOT=yes
IPADDR=192.168.37.6
NETMASK=255.255.255.0
IPV6_PRIVACY=no
VLAN=yes
NETWORK=192.168.37.0

#vi ifcfg-ens39.10
BOOTPROTO=none
IPV6INIT=no
IPV6_AUTOCONF=no
IPV6_DEFROUTE=no
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens39.10
DEVICE=ens39.10
ONBOOT=yes
IPADDR=192.168.100.2
NETMASK=255.255.255.0
IPV6_PRIVACY=no
VLAN=yes
NETWORK=192.168.100.0

#reboot

#ip a
3: ens39: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:91:46:7c brd ff:ff:ff:ff:ff:ff
    inet6 fe80::7001:8dc9:3973:e63c/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
4: ens39.5@ens39: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:0c:29:91:46:7c brd ff:ff:ff:ff:ff:ff
    inet 192.168.37.6/24 brd 192.168.37.255 scope global noprefixroute ens39.5
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe91:467c/64 scope link
       valid_lft forever preferred_lft forever
5: ens39.10@ens39: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:0c:29:91:46:7c brd ff:ff:ff:ff:ff:ff
    inet 192.168.100.2/24 brd 192.168.100.255 scope global noprefixroute ens39.10

[root@server2 network-scripts]# cat /proc/net/vlan/ens39.5
ens39.5  VID: 5  REORDER_HDR: 1  dev->priv_flags: 1021
         total frames received            3
          total bytes received          138
      Broadcast/Multicast Rcvd            0

      total frames transmitted           16
       total bytes transmitted         1132
Device: ens39
INGRESS priority mappings: 0:0  1:0  2:0  3:0  4:0  5:0  6:0 7:0
 EGRESS priority mappings:
[root@server2 network-scripts]# cat /proc/net/vlan/ens39.10
ens39.10  VID: 10        REORDER_HDR: 1  dev->priv_flags: 1021
         total frames received            3
          total bytes received          138
      Broadcast/Multicast Rcvd            0

      total frames transmitted           16
       total bytes transmitted         1132
Device: ens39
INGRESS priority mappings: 0:0  1:0  2:0  3:0  4:0  5:0  6:0 7:0
 EGRESS priority mappings:
[root@server2 network-scripts]#


==================================

vconfig 이용 방법
# vconfig add ens37 20
# cat /proc/net/vlan/config  //vlan 생성한것 확인

#ifconfig ens37.20 192.168.20.1 netmask 255.255.255.0 up
#vconfig rem ens37.20   //삭제

==============================
ip link 이용 방법

#ip link add link ens37 name ens37.30 type vlan id 30
#ip link show ens37.30
# ip link delete eth37.30   //삭제
#ip a
 

net711.tistory.com/entry/Linux-Vlan-%ED%95%A0%EB%8B%B9%ED%95%98%EC%97%AC-tag%EB%A1%9C-interface-%EA%B5%AC%EC%84%B1

 

[Network] Vlan 할당하여 tag로 interface 구성

리눅스에서 vlan을 tag(태깅)해서 사용하는 방법 우선 vlan 태깅을 위해서는 관련 모듈이 필요하다. 기본적으로 OS에 있지만 혹시 모르니 확인해주도록 한다. # modinfo 8021q # lsmod | grep 8021q 만약 모듈

net711.tistory.com

 

www.redhat.com/sysadmin/vlans-configuration

 

How to configure a VLAN in Linux

The opinions expressed on this website are those of each author, not of the author's employer or of Red Hat. The content published on this site are community contributions and are for informational purpose only AND ARE NOT, AND ARE NOT INTENDED TO BE, RED

www.redhat.com

 

'linux' 카테고리의 다른 글

centos - keepalived (링크 이중화 vrrp)  (0) 2021.01.03
centos - multipath + iscsi 설정  (0) 2021.01.02
centos teaming 티밍 - activebackup  (0) 2020.12.31
centos - 초기세팅  (0) 2020.12.30
Centos -backup  (0) 2020.12.29