반응형

 

1. routing table이란,

  • 네트워크상의 특정 목적지로 가는 경로 정보를 명시하고 있는 표

 

2. routing table 확인 (route)

command(type 1) : $ route or $ route -n or $ netstat -nr
목적지 IP 가 어느 Interface와 Gateway로 전달되는지 표시한다


  $ route
  Kernel IP routing table
  Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
  default         211.111.211.1   0.0.0.0         UG    0      0        0 eth0
  10.0.0.0        172.16.10.1     255.0.0.0       UG    0      0        0 eth1
  172.16.10.0     *               255.255.255.0   U     0      0        0 eth1
  211.111.211.0   *               255.255.255.128 U     0      0        0 eth0
  192.168.0.0     172.16.10.1     255.255.0.0     UG    0      0        0 eth1
  $
  $ netstat -nr
  Kernel IP routing table
  Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
  0.0.0.0         211.111.211.1   0.0.0.0         UG        0 0          0 eth0
  10.0.0.0        172.16.10.1     255.0.0.0       UG        0 0          0 eth1
  172.16.0.0      172.16.10.1     255.240.0.0     UG        0 0          0 eth1
  172.16.10.0     0.0.0.0         255.255.255.0   U         0 0          0 eth1
  211.111.211.0   0.0.0.0         255.255.255.128 U         0 0          0 eth0
  192.168.0.0     172.16.10.1     255.255.0.0     UG        0 0          0 eth1
  $
  

command(type 2) : $ ip route show or $ ip route list
내용은 동일하고 표현방법이 조금 다르다


$ ip route show
default via 211.111.211.1 dev eth0
10.0.0.0/8 via 172.16.10.1 dev eth1
172.16.0.0/12 via 172.16.10.1 dev eth1
172.16.10.0/24 dev eth1  proto kernel  scope link  src 172.16.10.45
211.111.211.0/25 dev eth0  proto kernel  scope link  src 183.111.198.45
192.168.0.0/16 via 172.16.10.1 dev eth1
$
$ ip route list
default via 211.111.211.1 dev eth0
10.0.0.0/8 via 172.16.10.1 dev eth1
172.16.0.0/12 via 172.16.10.1 dev eth1
172.16.10.0/24 dev eth1  proto kernel  scope link  src 172.16.10.45
211.111.211.0/25 dev eth0  proto kernel  scope link  src 183.111.198.45
192.168.0.0/16 via 172.16.10.1 dev eth1
$
반응형

3. routing table gateway 추가/삭제 (route add/del default gw)

3.1) gateway 경로 추가 (route add default gw)

리눅스 최초 설정으로 default gateway 경로가 없을 때 또는 gateway route ip가 바뀌었을 때 기존 경로 후 삭제 후 추가한다.
command(type 1) : $ route add default gw (gateway-ip-address) (interface-name)


$ route add default gw 211.111.211.1 eth0
$

command(type 2) : $ route add default gw (gateway-ip-address) netmask (netmask-address) dev (interface-name)


$ route add default gw 211.111.211.1 netmask 255.255.255.0 dev eth0

3.2) gateway 경로 삭제 (route del default gw)

경로 삭제할 때는 device interface name은 지정하지 않는다.
command : $ route del default gw (gateway-ip-address)


$ route del default gw 211.111.211.1
$

4. routing table 특정 목적지 경로 추가/삭제 (route add/del -net)

특정 목적지 IP로 가는 경로의 디바이스명을 추가/삭제 설정한다.

4.1) 특정 목적지 경로 추가 (route add -net)

command : $ route add -net (target-ip) netmask (netmask-address) dev (interface-name)


$ route add -net 172.16.10.0 netmask 255.255.255.0 dev eth1
$

4.2) 특정 목적지 경로 삭제 (route del -net)

command : $ route del -net (target-ip) netmask (netmask-address) dev (interface-name)


$ route del -net 172.16.10.0 netmask 255.255.255.0 dev eth1
$
반응형

+ Recent posts