2013/10/18

Network interface in Ubuntu

Here are notes about how to configure ubuntu's network setting without GUI.

Make sure you are root.

System: Ubuntu 12.04
Manual page: interfaces (5)

$>vi /etc/network/interfaces


auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
        dns-nameservers 8.8.8.8
        address 192.168.0.22
        netmask 255.255.255.0

        gateway 192.168.0.1

$>/etc/init.d/networking restart

PS
1. auto eth0 is necessary otherwise your eth0 will not be up on system startup
2. dns-nameservers option will override /etc/resolvd.conf. 

Reference link
https://help.ubuntu.com/10.04/serverguide/network-configuration.html

By the way, commands for run-time network interface's configuration
#Static
sudo ifconfig eth0 10.0.0.100 netmask 255.255.255.0
#DHCP
sudo dhclient eth0
#STOP DHCP
ps aux | grep dhcli
kill .....

沒有留言:

張貼留言