ubuntu 12.04 静态ip的设置方法
2017-04-04 15:26
567 查看
原文 http://blog.csdn.net/phpdata/article/details/12655733
ubuntu 12.04的网络设置文件是/etc/network/interfaces,打开文件,会看到
这边的设置是本地回路。在后面加上
其中eth0就是电脑的网卡,如果电脑有多块网卡,比如还会有eth1,都可以在这里进行设置。iface eth0 inet 设置为dhcp是动态获取IP,设置为static则用自定义的IP。这边要自定义IP地址,所以选择static选项。
重新启动网络服务
重启好后,用ifconfig看下eth0,是不是改成自己需要的IP地址了。
设置dns
ip设置好后,如果直接ping www.baidu.com会发现ping不通,因为dns还没设置,编辑/etc/resolv.conf,加上dns服务器地址。
这两个是Google提供的免费DNS服务器的IP地址。
(因为每次重启电脑后他系统都自动修改DNS配置文件 /etc/resolv.conf,所以每次都要重新设置,特别麻烦;
解决方案:
/etc/resolv.conf中的DNS配置是从/etc/resolvconf/resolv.conf.d/head中加载而来
所以可以直接修改 /etc/resolvconf/resolv.conf.d/head文件,即把
)
ubuntu 12.04的网络设置文件是/etc/network/interfaces,打开文件,会看到
auto lo iface lo inet loopback
这边的设置是本地回路。在后面加上
auto eth0 iface eth0 inet static address 192.168.1.230(ip地址) netmask 255.255.255.0(子网掩码) gateway 192.168.1.1(网关)
其中eth0就是电脑的网卡,如果电脑有多块网卡,比如还会有eth1,都可以在这里进行设置。iface eth0 inet 设置为dhcp是动态获取IP,设置为static则用自定义的IP。这边要自定义IP地址,所以选择static选项。
重新启动网络服务
sudo /etc/init.d/networking restart
重启好后,用ifconfig看下eth0,是不是改成自己需要的IP地址了。
设置dns
ip设置好后,如果直接ping www.baidu.com会发现ping不通,因为dns还没设置,编辑/etc/resolv.conf,加上dns服务器地址。
nameserver 8.8.8.8 nameserver 8.8.4.4
这两个是Google提供的免费DNS服务器的IP地址。
(因为每次重启电脑后他系统都自动修改DNS配置文件 /etc/resolv.conf,所以每次都要重新设置,特别麻烦;
解决方案:
/etc/resolv.conf中的DNS配置是从/etc/resolvconf/resolv.conf.d/head中加载而来
所以可以直接修改 /etc/resolvconf/resolv.conf.d/head文件,即把
nameserver 8.8.8.8 nameserver 8.8.4.4
两行追加到文件中
)
相关文章推荐
- Ubuntu 12.04 静态ip的设置方法
- Ubuntu 12.04 静态ip的设置方法
- ubuntu 12.04 静态ip的设置方法
- Ubuntu 12.04 静态ip的设置方法
- Ubuntu 12.04 静态ip的设置方法
- Ubuntu 12.04 静态ip的设置方法
- Ubuntu 12.04 静态ip的设置方法
- Ubuntu 12.04 静态ip的设置方法
- Ubuntu 12.04 静态ip的设置方法
- 解决vmware下装的ubuntu右上角显示网络禁用以及设置静态IP的方法
- 详解ubuntu14.04如何设置静态IP的方法
- Ubuntu设置静态IP的方法
- Ubuntu设置静态IP的方法
- Ubuntu静态ip的设置方法
- Ubuntu设置静态IP后无网络连接的解决方法
- ubuntu 设置静态IP的实现方法
- Ubuntu Server 12.04(14.04)配置静态IP的方法
- ubuntu设置静态IP的方法
- ubuntu设置静态ip的方法
- VMWARE中的UBUNTU虚拟机设置静态IP通过NAT上网的方法