라우팅
: 네트워크를 통해 목적지로 패킷이 전송될 경로를 지정해주는 것
route -n
: 라우트 설정 확인
[root@control ~]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default _gateway 0.0.0.0 UG 300 0 0 bond0
172.17.0.0 0.0.0.0 255.255.255.0 U 300 0 0 bond0
[root@control ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.17.0.1 0.0.0.0 UG 300 0 0 bond0
172.17.0.0 0.0.0.0 255.255.255.0 U 300 0 0 bond0
라우팅 테이블 필드

디폴트 게이트웨이 추가
[root@control ~]# route add default gw 172.17.0.2
[root@control ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.17.0.2 0.0.0.0 UG 0 0 0 bond0
0.0.0.0 172.17.0.1 0.0.0.0 UG 300 0 0 bond0
172.17.0.0 0.0.0.0 255.255.255.0 U 300 0 0 bond0
디폴트 게이트웨이 제거
[root@control ~]# route del default gw 172.17.0.2
[root@control ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.17.0.1 0.0.0.0 UG 300 0 0 bond0
172.17.0.0 0.0.0.0 255.255.255.0 U 300 0 0 bond0
임시적으로 라우팅 설정하기
네트워크 경로 추가
[root@control ~]# route add -net 172.17.1.0 netmask 255.255.255.0 gw 172.17.0.1
[root@control ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.17.0.1 0.0.0.0 UG 300 0 0 bond0
172.17.0.0 0.0.0.0 255.255.255.0 U 300 0 0 bond0
172.17.1.0 172.17.0.1 255.255.255.0 UG 0 0 0 bond0
네트워크 경로 제거
[root@control ~]# route del -net 172.17.1.0 netmask 255.255.255.0 gw 172.17.0.1
[root@control ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.17.0.1 0.0.0.0 UG 300 0 0 bond0
172.17.0.0 0.0.0.0 255.255.255.0 U 300 0 0 bond0
호스트 경로 추가
[root@control ~]# route add -host 172.17.1.100 gw 172.17.0.1
[root@control ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.17.0.1 0.0.0.0 UG 300 0 0 bond0
172.17.0.0 0.0.0.0 255.255.255.0 U 300 0 0 bond0
172.17.1.100 172.17.0.1 255.255.255.255 UGH 0 0 0 bond0
호스트 경로 제거
[root@control ~]# route del -host 172.17.1.100 gw 172.17.0.1
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.17.0.1 0.0.0.0 UG 300 0 0 bond0
172.17.0.0 0.0.0.0 255.255.255.0 U 300 0 0 bond0
영구적으로 라우팅 테이블 설정
라우팅 추가
[root@control ~]# nmcli con mod enp0s8 +ipv4.routes "192.168.0.0/24 10.0.0.110"
라우팅 제거
[root@control ~]# nmcli con mod enp0s8 -ipv4.routes "192.168.0.0/24 10.0.0.110"
라우팅 우선 순위 변경
# connection-name 확인
[root@control ~]# nmcli con
NAME UUID TYPE DEVICE
enp0s3 0513de10-4d94-3005-91bb-92d4231268cc ethernet enp0s3
lo 142becde-ac8a-4091-8816-c1c7b0b240aa loopback lo
# metric 변경
[root@control ~]# nmcli con mod enp0s3 ipv4.route-metric 101
# metric 변경 확인
[root@control ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.17.0.1 0.0.0.0 UG 101 0 0 enp0s3
172.17.0.0 0.0.0.0 255.255.255.0 U 101 0 0 enp0s3
'시리즈 > Linux 기초 다지기 2023 (개편 예정) - 시리즈' 카테고리의 다른 글
리눅스 기초 다지기 - 27. firewalld (0) | 2025.03.12 |
---|---|
리눅스 기초 다지기 - 26. resolv.conf (0) | 2025.03.12 |
리눅스 기초 다지기 - 24. bonding (0) | 2025.03.12 |
리눅스 기초 다지기 - 23. NetworkManager (0) | 2025.03.12 |
리눅스 기초 다지기 - 22. ethtool (2) | 2025.03.12 |