您的位置:首页 > 其它

ubuntu 启动时 设置多个ip 修改mac 网关 。。。

2011-11-29 09:58 686 查看
有时开发时要用到多个ip,还要改mac,在 /etc/network/interfaces这样写就可以达到 设置多个ip,改mac的目的

vi /etc/network/interfaces

auto lo

iface lo inet loopback

auto eth0

#auto eth0 inet dhcp

iface eth0 inet static
hwaddress ether 00:6d:04:60:2f:4a    //设置mac

address 192.168.0.222                         //第一个ip

netmask 255.255.255.0

gateway 192.168.0.1                             //第一个网关

auto eth0:0                                               //第二个ip

iface eth0:0 inet static

address 192.168.1.222

netmask 255.255.255.0

gateway 192.168.1.1

auto eth0:1                                             //第三个ip

iface eth0:1 inet static

address 10.10.0.2
netmask 255.255.255.0

gateway 10.10.0.1

dns-nameserever 8.8.4.4                     //dns

dns-nameserver 192.168.0.1

改后sudo /etc/init.d/networking restart 让设置生效

当然用命令也是可以改ip,mac的

改mac地址

ifconfig eth0 down

ifconfig eth0 hw ether 00:aa:bb:cc:dd:ee

ifconfig eth0 up

ifconfig eth0 192.168.0.22 netmask 255.255.255.0   //改ip

ifconfig eth0:0 192.168.1.22 netmask 255.255.255.0 //添加一个ip

route add default gw 192.168.0.1                        ///添网关

 

不过用改dns的 命令我还没发现。。。。有人发现可给我说下
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ubuntu