Ubuntu 1011中配置ip地址配有详细图.docx

上传人:b****5 文档编号:8023904 上传时间:2023-01-28 格式:DOCX 页数:18 大小:696.08KB
下载 相关 举报
Ubuntu 1011中配置ip地址配有详细图.docx_第1页
第1页 / 共18页
Ubuntu 1011中配置ip地址配有详细图.docx_第2页
第2页 / 共18页
Ubuntu 1011中配置ip地址配有详细图.docx_第3页
第3页 / 共18页
Ubuntu 1011中配置ip地址配有详细图.docx_第4页
第4页 / 共18页
Ubuntu 1011中配置ip地址配有详细图.docx_第5页
第5页 / 共18页
点击查看更多>>
下载资源
资源描述

Ubuntu 1011中配置ip地址配有详细图.docx

《Ubuntu 1011中配置ip地址配有详细图.docx》由会员分享,可在线阅读,更多相关《Ubuntu 1011中配置ip地址配有详细图.docx(18页珍藏版)》请在冰豆网上搜索。

Ubuntu 1011中配置ip地址配有详细图.docx

Ubuntu1011中配置ip地址配有详细图

Ubuntu10~11中配置ip地址(配有详细图)

一、直接修改UbuntuIP系统配置文件

UbuntuIP的网络配置文件是:

/etc/network/interfaces打开后里面可设置DHCP或手动设置静态ip。

前面autoeth0,让网卡开机自动挂载。

1.以DHCP方式配置网卡

(1)打开要编辑的文件interfaces它的的目录是/etc/network/interfaces

sudovi/etc/network/interfaces

或者:

sudogedit/etc/network/interfaces此时便可以在文本编辑器中编写文件中的内容,要方便多

(2)将文件里的内容改为:

autoeth0

ifaceeth0inetdhcp

(3)使用下面的命令使网络设置生效

sudo/etc/init.d/networkingrestart

(4)出了上面那种直接修改配置文件,如果要动态获取ip的话,还可以直接使用命令:

sudodhclienteth0

使用了此句后,网卡eth0的ip地址被设定为10.0.2.15,此时虚拟机可以ping通主机,且可以与主机共享上网。

(但是此时主机ping不通虚拟机)

2.为网卡配置静态UbuntuIP地址

(1)打开要编辑的文件interfaces它的的目录是/etc/network/interfaces

sudovi/etc/network/interfaces

或者:

sudogedit/etc/networking/interfaces此时便可以在文本编辑器中编写文件中的内容,要方便多

(2)将文件里的内容改为:

autoeth1

ifaceeth1inetstatic

address10.10.103.77

netmask255.255.255.0

gateway10.10.103.20

(3)配置DNS

sudogedit/etc/resolv.conf//使用此语句打开配置DNS的文件,修改即可

nameserver202.119.230.8

(4)使用下面的命令使网络设置生效

sudo/etc/init.d/networkingrestart

或者执行:

sudoifupeth1

执行此命令后,虚拟机的网卡eth1的ip地址被设定为10.10.103.77,此ip地址与主机ip地址在同一个网段中,此时主机便可以ping通虚拟机了。

(执行的前提是已经给此虚拟机设置了NAT和桥接方式)

二、实现主机和虚拟机之间相互通信

预备知识:

host-only模式下,主机相当于一台双网卡的电脑,物理网卡是外网,vmnet1是内网,此时虚拟机和主机通信的前提就是vmnet1的ip和虚拟机的ip在同一网段。

桥接模式下,主机和虚机相当于是两台接在同一交换机上的电脑,此时,虚拟机的ip地址应该和主机的物理网卡ip在同一网段,此时就能通信,当然包括也包括ping。

如果不通,可能跟防火墙有关系。

采用的方法是:

设置两个虚拟网卡,其中一个用NAT连接,以连接外网;一个用桥接,用来与主机互相通信。

步骤:

1、在启动虚拟机之前,在“Network”中默认设置第一块虚拟网卡(即用NAT方式)

,然后切换到Adapter2启用第二块虚拟网卡,并更改为桥接连接方式:

2、启动虚拟机,编辑eth1,在里面设置以太网接口eth1的IP地址、子网掩码和网关,这一步最为重要。

eth1这块网卡是桥接用的,即是与你主机互相通信用的,所以这里设置的IP要与主机的IP地址同个网段,网关和子网掩码就和主机的设置一致,然后设置IP为静态。

保存退出后,执行sudoifupeth1后便可以和主机互ping了。

3、使用sudodhclienteth0命令来动态分配eth0网卡的地址,可以看到设置后此IP为专有IP地址,用来NAT连接的,通过NAT转换之后就能上外网了。

4、用ifconfig查看网络接口信息,可以看到三个网卡,eth0,eth1,lo。

三、使用命令设置UbuntuIP地址(未实现!

(1)修改配置文件blacklist.conf禁用IPV6:

sudovi/etc/modprobe.d/blacklist.conf

(2)在文档最后添加blacklistipv6,然后查看修改结果:

cat/etc/modprobe.d/blacklist.conf

(3)设置UbuntuIP(设置网卡eth0的IP地址和子网掩码)sudoifconfigeth0192.168.2.1netmask255.255.255.0

(4)UbuntuIP设置网关sudorouteadddefaultgw192.168.2.254

(5)UbuntuIP设置DNS修改/etc/resolv.conf,在其中加入nameserverDNS的地址1和nameserverDNS的地址2完成。

(6)重启网络服务(若不行,请重启ubuntu:

sudoreboot):

sudo/etc/init.d/networkingrestart

(7)查看当前UbuntuIP:

ifconfig

四、ifconfig用法(未看)

无论是Linux自动安装还是我们手工安装,Linux都会向你询问有关网络的问题并配置相关的软件。

这个用于配置网卡的基本命令就是ifconfig。

在执行ifconfig命令后,系统将在内核表中设置必要的参数,这样Linux就知道如何与网络上的网卡通

信。

ifconfig命令有以下两种格式:

[php]viewplaincopyprint?

1※ifconfig

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(0,153,0);font-family:

inherit;font-style:

normal;font-weight:

normal;">[interface

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(0,153,0);font-family:

inherit;font-style:

normal;font-weight:

normal;">]

2※ifconfiginterface

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(0,153,0);font-family:

inherit;font-style:

normal;font-weight:

normal;">[aftype

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(0,153,0);font-family:

inherit;font-style:

normal;font-weight:

normal;">]option

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">|address…

ifconfig的第一种格式(或使用不带任何参数的ifconfig命令)可以用来查看当前系统的网络配置情况。

在刚刚安装完系统之后,实际上是在没有网卡或者网络连接的情况下使用Linux,但通过ifconfig可以使用回绕方式工作,使计算机认为自己工作在网络上。

现在我们运行一下ifconfig命令,不带参数的ifconfig命令可以显示当前启动的网络接口,其输出结果

为:

[php]viewplaincopyprint?

3

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(0,153,0);font-family:

inherit;font-style:

normal;font-weight:

normal;">[root

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">@machine1

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">/sbin

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(0,153,0);font-family:

inherit;font-style:

normal;font-weight:

normal;">]#ifconfig

4eth0

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(153,0,0);font-family:

inherit;font-style:

normal;font-weight:

normal;">Linkencap

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">:

EthernetHwaddr

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(204,102,204);font-family:

inherit;font-style:

normal;font-weight:

normal;">52

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">:

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(204,102,204);font-family:

inherit;font-style:

normal;font-weight:

normal;">54

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">:

AB

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">:

DD

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">:

6F

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">:

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(204,102,204);font-family:

inherit;font-style:

normal;font-weight:

normal;">61

5inetaddr

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">:

210

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">.34

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">.6

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">.89Bcast

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">:

210

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">.34

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">.6

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">.127Mask

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">:

255

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">.255

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">.255

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">.128

6UPBROADCASTRUNNINGMULTICASTMTU

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">:

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(204,102,204);font-family:

inherit;font-style:

normal;font-weight:

normal;">1500Metric

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">:

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(204,102,204);font-family:

inherit;font-style:

normal;font-weight:

normal;">1

7RXpackets

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">:

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(204,102,204);font-family:

inherit;font-style:

normal;font-weight:

normal;">46299errors

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;font-weight:

normal;">:

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(204,102,204);font-family:

inherit;font-style:

normal;font-weight:

normal;">0dropped

0px;margin:

0px;padding:

0px;text-align:

left;color:

rgb(51,153,51);font-family:

inherit;font-style:

normal;

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 小学作文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1