IP命令行配置如下
vi /etc/network/interfaces
DHCP
DHCP配置如下(假设通过eth1上网)
# The primary network interface - use DHCP to find our address
auto eth1
iface eth1 inet dhcp //指定为dhcp
然后重启
/etc/init.d/networking restart
Static IP
静态IP地址配置如下(假设通过eth1上网)# The primary network interface
auto eth1
iface eth1 inet static //指定为static
address 192.168.3.90 //IP地址
gateway 192.168.3.1 //网关
netmask 255.255.255.0 //子网掩码
同样需要重启
/etc/init.d/networking restart
DNS
如果有必要,配置DNS
vi /etc/resolv.conf
nameserver 192.168.3.2
另外有详细的解释:
Ubuntu的网络参数保存在文件 /etc/network/interfaces中,默认设置使用dhcp,内容如下:
# The primary network interface
auto eth0
iface eth0 inet dhcp
设置静态ip的方法如下:
1) 编辑 /etc/network/interfaces
1.1)将dhcp 一行屏蔽
# The primary network interface
auto eth0
#iface eth0 inet dhcp
1.2)添加和静态ip有关的参数
# The primary network interface
iface eth0 inet static
address 192.168.0.10
netmask 255.255.255.0
gateway 192.168.0.1
2)编辑 /etc/resolv.conf,设置dns
nameserver 202.96.134.133
nameserver 202.106.0.20
ifdown eth0
ifup eth0