- CentOS 기본 게이트웨어 변경
- /etc/sysconfig/network
1 임시 적용[ | ]
재부팅하면 사라짐.
- 명령어
Bash
Copy
route add default gw 게이트웨이주소 장치명
- 실행예시
Console
Copy
[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 영구 적용[ | ]
재부팅 후에도 적용됨.
- 명령어
Bash
Copy
echo 'GATEWAY=게이트웨이주소' >> /etc/sysconfig/network
service network restart
- 실행예시
Console
Copy
[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 로 상태 확인
3 같이 보기[ | ]
4 참고[ | ]
편집자 Jmnote bot Jmnote
로그인하시면 댓글을 쓸 수 있습니다.
- 분류 댓글:
- 리눅스 네트워크 (5)
리눅스 hosts 파일 ― 올해대박리눅스 hosts 파일 ― Jmnote리눅스 nc 포트 열기 ― …우분투 절전모드 해제시 와이파이 안되는 문제 ― D4RT우분투 절전모드 해제시 와이파이 안되는 문제 ― Beyondthelimit