HP-UX
1748182 회원
3484 온라인
108759 솔루션
새 메시지

route add 및 delete 에 관한 자료

 
seok gyu Min
비정기 조언자

route add 및 delete 에 관한 자료

route add 및 delete 에 관한 자료를 부탁 드립니다...

그 이유는

route add 10.200.1.1 10.200.1.1 netmask 255.255.255.0 1

을 하면 flage에서 UHG 라고 생기는데...

defalut gateway는 현재 등록 되어 있습니다...



자세한 자료 부탁 드립니다....
1 응답 1
이연주
정기 조언자

route add 및 delete 에 관한 자료

안녕하세요

예를들어 netstat명령어로 routing table을 보았을때 다음과 같이 나올겁니다.

# netstat -rn

Dest/Netmask Gateway Flags Refs Interface Pmtu

127.0.0.1 127.0.0.1 UH 0 lo0 4136

127.1.1.1 128.1.1.1 UH 0 lan0 4136

127.0.0.0 127.0.0.1 U 0 lo0 4136

128.1.0.0 128.1.1.1 U 0 lan0 1500

default 128.1.0.254 UG 0 lan0 1500



여기서보면 flag 상태가 있는데 여기서 flag값의 의미는 다음과 같습니다.

U = Route is "UP"

H = Route is for a single host

G = Route requires a hop across a gateway



즉 다시 말씀드리자면 UP은 destination까지의 경로가 살아있다는 얘기입니다. 거의 대부분은 다 UP상태입니다. 그리고 H는 destination이 network 주소가 아니라 single host일 경우가 됩니다. 그리고 G는 destination까지의 경로가 router를 거친다는것을 의미합니다. 그리고 U만 있는경우는 destination이 network주소일 경우입니다.



destination의 경로에서 router를 거치는 routing entry는 flag에 G가 나타나게 됩니다.



route command의 형식은 다음과 같습니다.



1. destination이 network 주소일 경우

route add net destination hop

route delete destination hop



2. destination이 host 주소일 경우



route add host destination hop

route delete destination hop



3. default gateway 추가



route default hop hop_count

route delete default hop



여기서 hop count는 0과1입니다.



1 : hop이 router(gateway)의 주소일 경우

0 : hop이 localhost일 경우(hop count 생략할 경우 0 이 default)

cf) default gateway 추가시는 hop count는 무조건 1이 되는거죠.



4. # route -f

=> 여기서 f 옵션은 flush option으로 라우팅 테이블에서 모든

gateway entry가 삭제됩니다.



route 명령어로 routing entry를 추가 삭제하는 경우는 일시적인 설정이기 때문에 시스템 재부팅 후에는 없어집니다.

그러므로 영구적으로 설정하기 위해서는 /etc/rc.config.d/netconf

파일에 설정하시면 됩니다.

예를 들자면 다음과 같이 설정하시면 됩니다.

/etc/rc.config.d/netconf

...

...

ROUTE_DESTINATION="net 129.1.0.0"

ROUTE_MASK="255.255.0.0"

ROUTE_GATEWAY="128.1.0.254"

ROUTE_COUNT="1"

ROUTE_ARGS=""



ROUTE_DESTINATION="default

ROUTE_MASK=""

ROUTE_GATEWAY="128.1.0.254"

ROUTE_COUNT="1"

ROUTE_ARGS=""

...

...



=> 이 파일에 적용된 routing entry는 /sbin/init.d/net이라는 script가 실행(#/sbin/init.d/net start)되면서 다음과 같이 적용됩니다.

이 script는 시스템 부팅시마다 자동으로 실행이 됩니다.



route add net 129.1.0.0 netmask 255.255.0.0 128.1.0.254 1

route add default 128.1.0.254 1