码迷,mamicode.com
首页 > 系统相关 > 详细

ubuntu/centos网络配置

时间:2015-08-29 16:36:10      阅读:265      评论:0      收藏:0      [点我收藏+]

标签:

UBUNTU网络配置

配置临时的Ip

  ifconfig eth0 192.168.3.136/24

其中24指的网络掩码24位。

  vim /etc/network/interfaces 添加下面内容

  auto eth0                   #开机自动连接

  iface eth0 inet static  #静态IP

  address 192.168.1.112

  netmask 255.255.255.0

  gateway 192.168.1.1

如果是dhcp,添加

  auto eth0

  iface eth0 inet dhcp

DNS配置:

vim /etc/resolv.conf

      nameserver 202.96.128.166

  nameserver 202.96.134.133

  nameserver 8.8.8.8

在resolv.conf文件中添加一些DNS服务器(例如电信)的IP地址即可。

网络重启:

  sudo /etc/init.d/networking restart

关闭网卡:

  sudo ifconfig eth0 down

打开网卡

  sudo ifconfig eth0 up

 

centos网络配置

在networ-scripts目录下,不同的网卡对应不同的配置文件。

sudo vim /etc/sysconfig/network-scripts/ifcfg-eth0

  DEVICE=eth0

  IPADDR=192.168.3.136

  NETMASK=255.255.255.0

  GATEWAY=192.168.3.1

  HWADDR=00:0C:29:C1:78:F6

  ONBOOT=yes      #开机启动

  NM_CONTROLLED=yes

  BOOTPROTO=static

DNS配置

vim /etc/resolv.conf

  nameserver 202.96.128.166

  nameserver 202.96.134.133

服务重启:

      sudo service network restart

启动

  sudo service network start

关闭

  sudo service network stop

ubuntu/centos网络配置

标签:

原文地址:http://www.cnblogs.com/helloworldtoyou/p/4769201.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!