본문 바로가기
Infra & DevOps/Linux

[퍼온 글] CentOS 게이트웨이 확인 및 설정

by Jordy-torvalds 2020. 6. 16.
반응형

출처: https://zetawiki.com/wiki/%EB%A6%AC%EB%88%85%EC%8A%A4_%EA%B2%8C%EC%9D%B4%ED%8A%B8%EC%9B%A8%EC%9D%B4_%ED%99%95%EC%9D%B8

 

리눅스 게이트웨이 확인 - 제타위키

다음 문자열 포함...

zetawiki.com

https://zetawiki.com/wiki/CentOS_%EA%B8%B0%EB%B3%B8_%EA%B2%8C%EC%9D%B4%ED%8A%B8%EC%9B%A8%EC%9D%B4_%EB%B3%80%EA%B2%BD

 

CentOS 기본 게이트웨이 변경 - 제타위키

CentOS 기본 게이트웨어 변경 /etc/sysconfig/network 1 임시 적용[편집] 재부팅하면 사라짐. 명령어 route add default gw 게이트웨이주소 장치명 실행예시 [root@zetawiki ~]# route Kernel IP routing table Destination Gateway

zetawiki.com

1 개요[편집]리눅스 디폴트 게이트웨이 확인리눅스 기본 게이트웨이 확인리눅스 게이트웨이 확인

  • 윈도우에서는 ipconfig 명령어로 확인 가능하지만, 리눅스 ifconfig는 게이트웨이를 보여주지 않는다.
  • 대신 route 명령어 또는 netstat 명령어를 통해 확인할 수 있다.

2 방법 1: route[편집]

[root@zetawiki ~\]# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 172.27.0.0 \* 255.255.0.0 U 0 0 0 eth0 link-local \* 255.255.0.0 U 1002 0 0 eth0 default 172.27.0.1 0.0.0.0 UG 0 0 0 eth0

이더넷 인터페이스는 1개(eth0)이며, 게이트웨이는 172.27.0.1

3 방법 2: netstat[편집]

[root@zetawiki ~\]# netstat -r Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 172.27.0.0 \* 255.255.0.0 U 0 0 0 eth0 link-local \* 255.255.0.0 U 0 0 0 eth0 default 172.27.0.1 0.0.0.0 UG 0 0 0 eth0

→ 이더넷 인터페이스는 1개(eth0)이며, 게이트웨이는 172.27.0.1

4 방법 3: ip[편집]

root@zetawiki:~# ip route default via 172.27.0.1 dev eth0 172.27.0.0/16 dev eth0 proto kernel scope link src 172.27.0.123

→ 게이트웨이는 172.27.0.1

1 임시 적용[편집]

재부팅하면 사라짐.

명령어

route add default gw 게이트웨이주소 장치명

실행예시

[root@zetawiki ~\]# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.0.0 \* 255.255.255.0 U 1 0 0 eth1 default 192.168.0.1 0.0.0.0 UG 0 0 0 eth1

[root@zetawiki ~\]# route add default gw 192.168.0.2 eth1

[root@zetawiki ~\]# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.0.0 \* 255.255.255.0 U 1 0 0 eth1 default 192.168.0.2 0.0.0.0 UG 0 0 0 eth1 default 192.168.0.1 0.0.0.0 UG 0 0 0 eth1

→ default 게이트웨이를 변경하면 네트워크가 안될 수도 있으니 주의!

2 영구 적용[편집]

재부팅 후에도 적용됨.

명령어

echo 'GATEWAY=게이트웨이주소' >> /etc/sysconfig/network service network restart

실행예시

[root@zetawiki ~\]# cat /etc/sysconfig/network NETWORKING=yes HOSTNAME=zetawiki

[root@zetawiki ~\]# cat /etc/sysconfig/network

[root@zetawiki ~\]# cat /etc/sysconfig/network NETWORKING=yes HOSTNAME=zetawiki GATEWAY=192.168.0.1 \[root@zetawiki ~\]# service network restart Shutting down interface eth0: \[ OK \] Shutting down interface eth1: \[ OK \] Shutting down loopback interface: \[ OK \] Bringing up loopback interface: \[ OK \] Bringing up interface eth0: \[ OK \] Bringing up interface eth1: \[ OK \]

→ 변경 전후 cat /etc/sysconfig/network와 route 로 상태 확인

반응형