使用命令设置ubuntu的ip地址

使用命令设置ubuntu的ip地址

 

使用命令设置ubuntu的ip地址

1.修改配置文件blacklist.conf禁用IPV6
sudo vi /etc/modprobe.d/blacklist.conf
添加如下:
blacklist ipv6

2.设置IP(设置网卡eth0的IP地址和子网掩码)
sudo ifconfig eth0 192.168.1.1 netmask 255.255.255.0

3.设置网关
sudo route add default gw 192.168.1.1

4.设置DNS(这里使用阿里云DNS http://alidns.com/setup/#linux)
sudo vi /etc/resolv.conf
加入:
nameserver 223.5.5.5
nameserver 223.6.6.6

也可以使用114DNS (http://www.114dns.com/)
114.114.114.114,114.114.115.115
114.114.114.119,114.114.115.119
114.114.114.110,114.114.115.110

或者Google DNS
8.8.8.8和8.8.4.4

5.重启网络服务
sudo /etc/init.d/networking restart


6.查看当前IP
ifconfig

posted @ 2015-01-04 18:06  一片相思林  阅读(1125)  评论(0)    收藏  举报