[ubuntu] 配置ip

vim /etc/network/interfaces
引用

auto eth0
iface eth0 inet static
address 192.168.5.89
netmask 255.255.255.0
gateway 192.168.1.1
pre-up ifconfig eth0 hw ether 00:11:22:33:44:55 #修改mac地址


配置完重启:
#sudo /etc/init.d/networking restart

配置DNS
首先,你可以在/etc/hosts中加入一些主机名称和这些主机名称对应的IP地址,这是简单使用本机的静态查询.
要访问DNS 服务器来进行查询,需要设置/etc/resolv.conf文件.
假设DNS服务器的IP地址是192.168.3.2, 那么/etc/resolv.conf文件的内容应为:
search test.com
nameserver 192.168.3.2

设定第二个IP地址(虚拟IP地址)
编辑文件/etc/network/interfaces:
#sudo vi /etc/network/interfaces
在该文件中添加如下的行:
引用
auto eth0:1
iface eth0:1 inet static
address 192.168.1.60
netmask 255.255.255.0
network x.x.x.x
broadcast x.x.x.x
gateway x.x.x.x

根据你的情况填上所有诸如address,netmask,network,broadcast和gateways等信息.
用下面的命令使网络设置生效:
#sudo /etc/init.d/networking restart

猜你喜欢

转载自iaiai.iteye.com/blog/1103027