I.K.Picture & IT Info.

[CentOS7] 멀티 NIC 설정하기 (Ubuntu도 가능) 본문

Desktop and Mobile/Linux

[CentOS7] 멀티 NIC 설정하기 (Ubuntu도 가능)

helpful-intruder 2020. 4. 16. 13:44
반응형

이전에, Ubuntu에서 멀티 NIC일 경우 게이트웨이 설정하는 방법에 대해 포스팅을 한적 있습니다.

뭐 CentOS도 크게 다르지 않지만 설정 위치가 조금 다르기 때문에 

따로 포스팅을 하고자합니다.

혹시나 Ubuntu에 대한 설정을 확인하려면

2020/01/18 - [Desktop and Mobile/Linux] - [ubuntu] netplan 으로 변경된 18.04 LTS에 멀티 NIC

2018/10/02 - [Desktop and Mobile/Linux] - [ubuntu] 멀티 NIC 일 경우 게이트웨이 설정

 

[ubuntu] 멀티 NIC 일 경우 게이트웨이 설정

일반적으로 Ubuntu에서 네트워크를 설정할 때 사용되는 설정입니다. 설정 파일은 /etc/network/interfaces 파일이구요 이 안에 네트워크 인터페이스 이름이 enp5s0 라고 가정하면 auto enp5s0 iface enp5s0 inet s..

blog.engintruder.com

 

위 두 포스터를 확인하시면됩니다. 

 

자, 그럼 CentOS에서의 설정법 설명하도록 하겠습니다. 

 

라우팅 테이블 위치 /etc/iproute2/rt_tables 

네트워크 관련 설정 위치 /etc/sysconfig/network-scripts/*

 

먼저 라우팅 테이블에 원하는 이름으로 2개를 세팅합니다.

(전 일괄성을 위해 위 포스팅과 동일한 아이피 및 nic 이름으로 작성하였습니다.)

반드시 세팅 전 자신의 nic 이름은 알고 계셔야되요 

eth*, enp*s*  뭐 이런식으로 이름이 되어 있을꺼예요

 

#vi /etc/iproute2/rt_table

기존 작성되어 있는거 건드리지 말고 맨 아래로 내려가

 

10 enp5table

11 enp6table

 

다음 아래와 같이 파일 4개를 만든다 위치는 당연히 네트워크 관련 설정 위치에...

#vi /etc/sysconfig/network-script/route-enp5s0

192.168.0.0 dev enp5s0 src 192.168.0.7 table enp5table
default via 192.168.0.1 dev enp5s0 table enp5table

#vi /etcsysconfig/network-script/rule-enp5s0

from 192.168.0.7/32 table enp5table
to 192.168.0.7 table enp5table

#vi /etc/sysconfig/network-script/route-enp6s0

192.168.1.0 dev enp6s0 src 192.168.1.7 table enp5table
default via 192.168.1.1 dev enp5s0 table enp5table

#vi /etcsysconfig/network-script/rule-enp6s0

from 192.168.1.7/32 table enp6table
to 192.168.1.7 table enp5table

 

이렇게만 설정할 경우 재부팅을 해야 적용됩니다. 

 

만약 재부팅을 하기 전 바로 적용되는 것을 확인하고 싶으신 경우

#ip route add 192.168.0.0/24 dev enp5s0 src 192.168.0.7 table enp5table

#ip route add default via 192.168.0.1 dev enp5s0 table enp5table

#ip rule add from 192.168.0.7/32 table enp5table

#ip rule add to 192.168.0.7 table enp5table

 

#ip route add 192.168.1.0/24 dev enp6s0 src 192.168.1.7 table enp5table

#ip route add default via 192.168.1.1 dev enp6s0 table enp5table

#ip rule add from 192.168.1.7/32 table enp5table

#ip rule add to 192.168.1.7 table enp5table

 

이렇게 하시면됩니다. 

반응형
Comments