Linux(CentOS7) 가상 네트워크 인터페이스 추가

NAT 구성 등을 위한 가상 인터페이스를 추가하는 방법을 설명알아보자.

인터페이스 정보 확인

[root@localhost ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.192.252  netmask 255.255.255.0  broadcast 192.168.192.255
        inet6 fe80::6d05:37d3:fb10:5b25  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:67:a4:a6  txqueuelen 1000  (Ethernet)
        RX packets 411  bytes 36267 (35.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 329  bytes 31013 (30.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 96  bytes 8376 (8.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 96  bytes 8376 (8.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

가상 인터페이스 생성
물리 인터페이스를 공유할 인터페이스 생성
ens33의 물리 NIC를 사용할 경우 ens33:0으로 생성한다.

[root@localhost ~]# cp /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-ens33:0              
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33:0
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
# 인터페이스 명과 장치명이 겹치지 않도록 수정한다.
NAME=ens33:0
DEVICE=ens33:0
ONBOOT=yes

# 사용하고 싶은 IP로 변경한다.
IPADDR=192.168.192.253
PERFIX=24
GATEWAY=192.168.192.254

확인

[root@localhost ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.192.252  netmask 255.255.255.0  broadcast 192.168.192.255
        inet6 fe80::6d05:37d3:fb10:5b25  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:67:a4:a6  txqueuelen 1000  (Ethernet)
        RX packets 1046  bytes 93843 (91.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 703  bytes 78865 (77.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens33:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.192.253  netmask 255.255.255.0  broadcast 192.168.192.255
        ether 00:0c:29:67:a4:a6  txqueuelen 1000  (Ethernet)

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 104  bytes 9080 (8.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 104  bytes 9080 (8.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

인터페이스 정보를 확인하고 연결이 되는지 확인한다.

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Users\haedong> ssh haedong@192.168.192.253
The authenticity of host '192.168.192.253 (192.168.192.253)' can't be established.
ECDSA key fingerprint is SHA256:en-----------------------0s3gUedMt8.
Are you sure you want to continue connecting (yes/no/[fingerprint])?

댓글 남기기