您的位置:首页 > 理论基础 > 计算机网络

Ubuntu 网络配置

2012-07-13 12:35 459 查看
1. 网络配置文件:/etc/network/interfaces

如果通过DHCP来获取IP地址的,默认interfaces文件看起来是:

auto lo
iface lo inet loopback

 如果要手工指定IP地址,则要把DHCP关键字改为scatic:

   auto lo
   iface lo inet static
   address 192.168.1.10

   netmask 255.255.255.0

   gateway 192.168.1.1

配置好后,重启服务:

 sudo /etc/init.d/networking restart

2. 域名服务器配置文件:/etc/resolv.conf

 默认配置看上去是:

 # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
 # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
 nameserver 127.0.0.1

 如果有要修改DNS服务器地址,则可以把上面的IP地址替换掉

3. /etc/hosts 文件

默认看上去像:

 127.0.0.1 localhost
 127.0.1.1 jeff-F6Ve
 

 # The following lines are desirable for IPv6 capable hosts
 ::1 ip6-localhost ip6-loopback
 fe00::0 ip6-localnet
 ff00::0 ip6-mcastprefix
 ff02::1 ip6-allnodes
 ff02::2 ip6-allrouters

默认情况下,进行域名解析时,系统会先查找/etc/hosts文件,再去查询DNS服务器,如果想更改这个顺序,可以修改/etc/nsswitch.conf 文件中 hosts一行的顺序。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: