본문 바로가기

컴퓨터(O/S)/Linux

[ubuntu/fedora] ip 주소 확인 및 변경

[ip 주소 확인] 모든 리눅스 공통.

ifconfig  - 모든 ip 정보 출력.
ifconfig [인터페이스번호] - 인터페이스에 해당하는 ip 정보만 출력.


[ubuntu]
vi /etc/network/interfaces (여기서 아이피 변경)

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static      
address 192.12.35.25
netmask 255.255.255.0
gateway 192.0.0.1

dns-nameservers 168.126.63.1 168.126.63.2



vi /etc/resolv.conf (여기서 dns 변경)
/etc/init.d/networking restart [재시작]

ip만 바로 변경하기. ( 전원이 꺼지면 복구 됨. 저장되지 않음. 일회성)
ifconfig [인터페이스번호] 아이피
ifconfig [인터페이스번호] 아이피 netmask 넷마스크

ex)
ifconfig eth0 192.168.5.200
ifconfig eth0 192.168.5.200 netmask 255.255.255.0

ifconfig 에 바로 아이피를 쓰면 dns가 변경된다고 함. 


[fedora]
vi /etc/sysconfig/network-scripts/ifgcfg-eth0   /ip변경.


service network restart                                  / 네트워크 재시작.
 or
/etc/init.d/network restart 



ip 또는 기타 네트워크 관련 정보를 수정했따면 반드시 네트워크를 재시작 해줘야 한다.