1、dhcp自动获取
sudo vi /etc/network/interfaces
auto eth0
iface eth0 inet dhcp

设置生效:

sudo /etc/init.d/networking restart

sudo dhclient eth0


2、静态IP地址
sudo vi /etc/network/interfaces

auto eth0
iface eth0 inet static
address 192.168.3.90

netmask 255.255.255.0
gateway 192.168.3.1

设置生效:

sudo /etc/init.d/networking restart


3、虚拟IP地址
sudo vi /etc/network/interfaces

添加:

auto eth0:1
iface eth0:1 inet static
address 192.168.1.60
netmask 255.255.255.0
gateway 192.168.1.1

设置生效:

sudo /etc/init.d/networking restart