본문 바로가기

Linux

Ubuntu IP 설정, DNS 설정과 default route 설정

ifconfig 명령어를 사용할경우 껐다 켜면 설정이 초기화 되기때문에 따로 설정

static ip 설정 및 DNS 설정

root@localhost:/# vim /etc/network/interfaces

<추가>
auto eth0
iface eth0 inet static
address 192.168.10.2
netmask 255.255.255.0
gateway 192.168.10.1
broadcast 192.168.10.255
dns-nameservers 168.126.63.1

저장후 종료 networking restart
root@localhost:/# /etc/init.d/networking restart

ifconfig로 ip확인
root@localhost:/#  ifconfig 

dns 확인
root@localhost:/# cat /etc/resolv.conf

이렇게 하면 내부로 ping은 가도 외부로 안간다. route 설정!!
route 명령어 칠경우 default route 설정이 안되있다. dhcp로 할경우는 자동으로 잡힘!
root@localhost:/#  route add default gw 192.168.10.1

route 명령어로 default route 추가된지 확인! (5초정도걸림)

그외 ssh port 변경후 nmap 없이 port 검색

netstat -na|grep [port or ssh]



p.s : 재부팅할 경우 default gw는 다시 설정해주어야 한다... 아직 자동으로 하는 방법을 못찾았다.. 굳이 하자면 스크립트로 할수 있는데 그것말고 다른 방법이 있겠지..

p.s2 : 혹시 apt-get update 할때
-5 - No address associated with hostname  <----- 에러가 뜰경우 대책

root@localhost:/# vim /etc/apt/sources.list
:%s/kr.archive.ubuntu.com/ftp.daum.net/g
:wq
root@localhost:/# apt-get update

원본 : http://leopardan.kr/156