首页 > 系统服务 > 详细

linux之网络配置相关

时间:2016-02-29 14:10:49      阅读:190      评论:0      收藏:0      [点我收藏+]

ubuntu的网络配置文件在 /etc/network/intrfaces;

suse的网络配置在          /etc/sysconfig/network/下面,每个网卡一个配置文件。

 

intrfaces如下内容表示使用DHCP分配IP:
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

 

Dynamic Host Configuration Protocol (DHCP) is a client/server protocol that automatically provides an Internet Protocol (IP) host with its IP address and other related configuration information such as the subnet mask and default gateway.

 

修改为如下表示配置静态IP地址:
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
#iface eth0 inet dhcp

iface eth0 inet static
address 192.168.80.129
netmask 255.255.255.0
gateway 192.168.80.2

注意:只需要设置address(IP地址)、netmask(子网掩码)、gateway(网关)这三项就OK,network和broadcast这两项参数是可以不写的。

 

设置DNS服务器

都在/etc/resolv.conf这个文件内配置。

内容:

nameserver 192.168.80.2
nameserver 8.8.8.8

保存退出。

注意:重启Ubuntu后发现又不能上网了,问题出在/etc/resolv.conf。重启后,此文件配置的dns又被自动修改为默认值。所以需要永久性修改DNS。方法如下:

# vim /etc/resolvconf/resolv.conf.d/base
nameserver 192.168.80.2
nameserver 8.8.8.8

3、重启networking服务使其生效:

# /etc/init.d/networking restart

这样网络配置就永久生效。

 

linux之网络配置相关

原文:http://www.cnblogs.com/kex1n/p/5227232.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!