现在的位置: 首页 > 综合 > 正文

Ubuntu Server 配置IP

2013年10月08日 ⁄ 综合 ⁄ 共 1307字 ⁄ 字号 评论关闭

转自:http://www.yimiju.com/articles/411.html

因为Ubuntu Server不像桌面版Ubuntu那样,可以非常简单的通过图形操作界面配置网卡IP。

所以Yimiju再此讲解下手动修改网卡IP的两种方法:

第一种方法:常规方法

1、登录Ubuntu Server,然后通过“sudo -s” 切换到root用户。

2、输入“cd /etc/network/”,回车,到network目录。

3、输入“ls”,回车,看看是否存在interfaces文件。

4、输入“vim interfaces”,回车,进去编辑界面。

5、按键盘上的“Insert”键,然后移动光标至你要修改的地方进行修改。

6、然后按“Esc”退出编辑,在按“Shift+:”输入“wq”,回车,保存并退出。

7、输入“reboot”重启,重启ubuntu之后你再用ifconfig看看,IP应该修改好了。

第二种:“临时性修改”

这里的“临时性修改”指的是你只需要临时性的给你的Ubuntu Server更换个内网IP,

方法很简单:

1、登录Ubuntu Server,然后通过“sudo -s”切换到root用户。

2、输入“ifconfig eth0 xxx.xxx.xxx.xxx”,回车。

eth指的是你的物理网卡,如果你的网卡号是eth1,那上面的命令也要做相应的修改。

xxx.xxx.xxx.xxx指的是你要指派的IP地址,例如:192.168.1.123.

注意:这种方法简单快速,但是只是临时修改了内网IP地址,重启ubuntu之后又会变回修改前的IP。

具体修改IP的方法:

Edit

$sudo vi /etc/network/interfaces

and adjust it to your needs (in this example setup I will use the IP address 192.168.0.100):

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# This is a list of hotpluggable network interfaces.
# They will be activated automatically by the hotplug subsystem.
mapping hotplug
        script grep
        map eth0

# The primary network interface
auto eth0
iface eth0 inet static
        address 192.168.0.100      # This is your IP
        netmask 255.255.255.0
        network 192.168.0.0
        broadcast 192.168.0.255
        gateway 192.168.0.1

Then do

sudo /etc/init.d/networking restart

to restart the network.

抱歉!评论已关闭.