快捷搜索:   nginx

ubuntu 通过/etc/network/interfaces文件永久设置static ip地址

手动配置ip,gateway和dns

longhtml@ubuntu:~$ sudo nano /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.1.251
netmask 255.255.255.0
gateway 192.168.1.254

接下来添加DNS
longhtml@ubuntu:~$ cat /etc/resolv.conf
# Generated by NetworkManager // 需要删除改行,否则每次重启ubuntu之后,/etc/resolv.conf将被清空

longhtml@ubuntu:~$ sudo nano /etc/resolv.conf
nameserver 202.96.128.188    //深圳电信
nameserver 202.96.134.133
nameserver 192.168.1.254

longhtml@ubuntu:~$ sudo /etc/init.d/networking restart
或者
longhtml@ubuntu:~$ sudo service networking restart

如果配置失败,可以使用手工配置方法:
longhtml@ubuntu:~$ sudo ifconfig eth0 192.168.1.251 netmask 255.255.255.0 up
longhtml@ubuntu:~$ sudo route add default gw 192.168.1.254 eth0

顶(0)
踩(0)

您可能还会对下面的文章感兴趣:

最新评论