develog

[linux] routing table 등록/삭제 본문

카테고리 없음

[linux] routing table 등록/삭제

냐옴 2022. 6. 20. 09:47

route 등록/삭제 방법

# 라우팅 테이블 확인
$ route -n

# default gateway 등록/삭제
sudo route add default gw 192.168.56.1 metric 200 dev enp0s8
sudo route del default gw 192.168.56.1 metric 200 dev enp0s8

# 네트워크 대역 등록/삭제
sudo route add -net 192.168.56.0 netmask 255.255.255.0 metric 200 dev enp0s8
sudo route del -net 192.168.56.0 netmask 255.255.255.0 metric 200 dev enp0s8

# 단일 호스트 등록/삭제
sudo route add -host 192.168.56.100 gw 192.168.56.1
sudo route del -host 192.168.56.100 gw 192.168.56.1

 

route 내용 보기

출력 화면 설명

OUTPUT
       The output of the kernel routing table is organized in the following columns

       Destination
              The destination network or destination host.

       Gateway
              The gateway address or '*' if none set.

       Genmask
              The netmask for the destination net; '255.255.255.255' for a host destination and '0.0.0.0' for the default route.

       Flags  Possible flags include
              U (route is up)
              H (target is a host)
              G (use gateway)
              R (reinstate route for dynamic routing)
              D (dynamically installed by daemon or redirect)
              M (modified from routing daemon or redirect)
              A (installed by addrconf)
              C (cache entry)
              !  (reject route)

       Metric The 'distance' to the target (usually counted in hops).

       Ref    Number of references to this route. (Not used in the Linux kernel.)

       Use    Count of lookups for the route.  Depending on the use of -F and -C this will be either route cache misses (-F) or hits (-C).

       Iface  Interface to which packets for this route will be sent.
Comments