<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>蝎子's life &#187; linux</title>
	<atom:link href="http://ohblue.com/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://ohblue.com</link>
	<description>蜘蛛般生活 -_-!</description>
	<lastBuildDate>Thu, 06 May 2010 13:01:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Ubuntu Server 下的网络配置</title>
		<link>http://ohblue.com/ubuntu-server-network-config/</link>
		<comments>http://ohblue.com/ubuntu-server-network-config/#comments</comments>
		<pubDate>Thu, 24 Jul 2008 11:00:56 +0000</pubDate>
		<dc:creator>蝎子</dc:creator>
				<category><![CDATA[笔记]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[网络]]></category>
		<category><![CDATA[配置]]></category>

		<guid isPermaLink="false">http://ohblue.com/?p=277</guid>
		<description><![CDATA[检查网络配置

$ ifconfig

配置DHCP客户端

<span class="readmore"><a href="http://ohblue.com/ubuntu-server-network-config/" title="Ubuntu Server 下的网络配置">阅读全文——共968字</a></span>]]></description>
			<content:encoded><![CDATA[<p><strong>检查网络配置</strong><br />
$ ifconfig</p>
<p><strong>配置DHCP客户端</strong><br />
$ sudo vi /etc/network/interfaces<br />
加入 iface eth0 inet dhcp</p>
<p><strong>配置静态IP地址</strong><br />
$ sudo vi /etc/network/interfaces<br />
eth0配置如下：<br />
auto eth0<br />
address 192.168.0.88<br />
netmask 255.255.255.0<br />
gateway 192.168.0.1</p>
<p><strong>让新配置生效</strong><br />
保存退出后，使用重启networking命令让新配置生效：<br />
$ sudo /etc/init.d/networking restart<br />
也可以重启网卡让新配置生效，优点是不影响其他网络接口：<br />
$ sudo ifdown eth0<br />
$ sudo ifup eth0<br />
<span id="more-277"></span><br />
<strong>临时改变IP地址</strong><br />
$ sudo ifconfig eth0 192.168.1.111 netmask 255.255.255.0<br />
当系统重启动后，后会恢复interfaces中的配置。</p>
<p><strong>设置默认网关</strong>的方法也有两种：<br />
1. 在interfaces文件中设置。<br />
$ sudo vi /etc/network/interfaces<br />
在eth0的相关配置下加入gateway，如：<br />
auto eth0<br />
iface eth0 inet static<br />
address 192.168.1.123<br />
netmask 255.255.255.0<br />
gateway 192.168.1.1</p>
<p>2. 直接用命令设置：<br />
删除当前缺省网关<br />
$ sudo route del default gw<br />
手工配置缺省网关<br />
$ sudo route add default gw 192.168.1.1<br />
查看路由信息<br />
$ route<br />
使用本方法，修改当即生效，重新启动后，则interfaces文件中的设置有效。</p>
<p><strong>查看主机名</strong><br />
$ hosts</p>
<p><strong>临时修改主机名</strong><br />
$ sudo hostname testserver<br />
执行完命令后，即时生效。</p>
<p><strong>永久修改主机名</strong><br />
$ sudo vi /etc/hostname<br />
把新的主机名写入即可。当系统重启后，会读出此文件中主机名。</p>
<p><strong>配置DNS服务器的地址</strong>，最多可以使用3个DNS服务器<br />
$ sudo vi /etc/resolv.conf<br />
nameserver 202.xx.xx.xx<br />
nameserver 192.168.1.1<br />
对”resolv.conf”的修改是即时生效的。可以使用nslookup命令进行DNS服务器查询，以验证”resolv.conf”配置文件。</p>
]]></content:encoded>
			<wfw:commentRss>http://ohblue.com/ubuntu-server-network-config/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

