[Linux] 가상 eth 구성

김봉남·2024년 2월 12일

Linux

목록 보기
27/36
post-thumbnail

간혹 서버 내에 가상 IP를 추가할 경우가 있다. HA 구성 시 서비스 IP나, 별도의 IP가 필요할 경우 아래와 같이 기존 eth 장치에 논리적으로 하나 더 추가할 수 있다.

/etc/sysconfig/network-scripts/ 디렉토리 내에 "ifcfg-eth0:0" 파일을 만들고 환경 설정을 하면 되는데 수동으로 "ifup eth0:0"을 실행 해줘야 된다.

[root@foo1 ~]# ifconfig

Example: This is a working example of the physical network interface configuration file (eth0:0):

/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1

And a working example of the alias network interface (eth0:0) on top of physical network interface (eth0):

/etc/sysconfig/network-scripts/ifcfg-eth0:0
DEVICE=eth0:0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.1.149
NETMASK=255.255.255.0
GATEWAY=192.168.1.1

By running ifup command, we bring alias network interface up and running:
[root@foo1 ~]# ifup eth0:0

Checking for alias network interface eth0:0 with the IP address 192.168.1.101 with ifconfig command:
[root@foo1 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:A9:01:61 
          inet addr:192.168.1.100  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fea9:161/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4726 errors:0 dropped:0 overruns:0 frame:0
          TX packets:732 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:542695 (529.9 KiB)  TX bytes:115702 (112.9 KiB)

eth0:0    Link encap:Ethernet  HWaddr 08:00:27:A9:01:61 
          inet addr:192.168.1.101  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:140 errors:0 dropped:0 overruns:0 frame:0
          TX packets:140 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:11760 (11.4 KiB)  TX bytes:11760 (11.4 KiB)
profile
남자다

0개의 댓글