linux实验手册
- 格式:doc
- 大小:439.50 KB
- 文档页数:48
LAB1==网络的基本配置
涉及的知识点:
1. 基本配置文件
/etc/hosts:是将IP地址和主机名联系起来的简单文本文件。
格式:IP地址 全限定主机名 别名
举例:192.168.0.2 wanghui
说明:将IP地址映射到,并且分配一个备用主机名wanghui。
实验拓扑
具体实验步骤:
编辑HOSTS文件:
[root@b root]# vi /etc/hosts
在HOST中添加一行:
192.168.1.202
用PING进行验证:
[root@b root]# ping 192.168.1.202
PING 192.168.1.202 (192.168.1.202) 56(84) bytes of data.
64 bytes from 192.168.1.202: icmp_seq=9 ttl=128 time=0.290 ms
64 bytes from 192.168.1.202: icmp_seq=10 ttl=128 time=0.293 ms
PING域名验证成功:
[root@b root]# ping
PING (192.168.1.202) 56(84) bytes of data.
64 bytes from (192.168.1.202): icmp_seq=1 ttl=128 time=0.342 ms
64 bytes from (192.168.1.202): icmp_seq=2 ttl=128 time=0.297 ms
LAB2==如何修改主机的名字?
涉及的知识点:
/etc/sysconfig/network:网络配置信息,系统启动时会引导这个文件。
内容:
NETWORKING=YES|NO 以太网:192.168.10.0/255.255.255.0工作站2:192.168.10.2工作站22:192.168.10.22工作站40:192.168.10.40工作站56:192.168.10.56工作站60:192.168.10.60网关:192.168.10.1其它网络工作站5:192.168.10.5YES表示需要配置网络,NO表示不需要配置网络;
HOSTNAME=homename
主机的全限定域名;
GATEWAY=gw-ip
网络网关的IP地址;
GATEWAYDEV=gw-dev
网络设备的名称(例如eth0或者IP地址);
NISDOMAIN=dom-name
表示NIS域(如果有的话)。
具体实验步骤:
编辑network文件:
[root@b root]# vi /etc/sysconfig/network
在HOSTNAME中把主机名修改为
NETWORKING=yes
HOSTNAME=
重启LINUX
[root@b root]# init 6
重新登陆linux中验证主机名
[root@b root]# hostname
LAB3===如何配置LINUX的网卡
1、涉及的知识点
可执行脚本和命令
/etc/rc.d/init.d/network {start|stop|restart|reload|status}
系统启动时的初始化脚本程序。
/etc/sysconfig/network-scripts/ifcfg-interface-name:网卡配置文件。
内容:
DEVICE=物理设备名
IPADDR=IP地址
NETMASK=掩码值
NETWORK=网络地址
BROADCAST=广播地址
GATEWAY=网关地址
ONBOOT=[yes|no](引导时是否激活设备)
USERCTL=[yes|no](非root用户是否可以控制该设备)
BOOTPROTO=[none|static|bootp|dhcp](引导时不使用协议|静态分配|BOOTP协议|DHCP协议)
ifconfig:命令用来在系统内核表中设置或读取网络设备参数
举例:ifconfig eth0 IP地址 netmask 子网掩码
说明:配置IP和子网
举例:ifconfig eth0 hw ether MAC地址 说明:配置mac地址
举例:ficonfig dynamic
说明:启动dhcp
举例:ifconfig eth0 [down|up]
说明:启动或关闭网卡
netconfig:通过通行界面配置网络。
具体步骤:
方法1:修改ifcfg-interface-name文件
[root@b root]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
修改好IP地址、网关等信息
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.2
NETMASK=255.255.255.0
GATEWAY=192.168.1.2
使配置生效
[root@b root]# /etc/rc.d/init.d/network restart
Shutting down interface eth0: OK ]
Shutting down loopback interface: OK ]
Setting network parameters: OK ]
Bringing up loopback interface: OK ]
Bringing up interface eth0: OK ]
[root@b root]# service network restart
验证是否修改成功
[root@b root]# ifconfig
eth0 Link encap:Ethernet
HWaddr 00:0C:29:FC:9A:A6
inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7387 errors:0 dropped:0 overruns:0 frame:0
TX packets:1453 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:709400 (692.7 Kb) TX bytes:104537 (102.0 Kb)
Interrupt:10 Base address:0x1080
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:570 errors:0 dropped:0 overruns:0 frame:0
TX packets:570 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:50022 (48.8 Kb) TX bytes:50022 (48.8 Kb)
方法2:使用netconfig
不详细叙述
方法3:使用Ifconfig命令
把主机的IP地址设置为192.168.1.250
[root@b root]# ifconfig eth0 192.168.1.250 netmask 255.255.255.0
验证是否修改成功
[root@b root]# ifconfig
eth0 Link encap:Ethernet
HWaddr 00:0C:29:FC:9A:A6
inet addr:192.168.1.250 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7387 errors:0 dropped:0 overruns:0 frame:0
TX packets:1453 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:709400 (692.7 Kb) TX bytes:104537 (102.0 Kb)
Interrupt:10 Base address:0x1080
LAB4==如何禁用和启动网卡?
LAB5==如何在LINUX中上网
LAB6==在linux中采用adsl拨号上网
配置拨号设置
Last login: Sat Jul 8 11:04:05 2006
[root@ns root]# adsl-setup
Welcome to the ADSL client setup. First, I will run some checks on
your system to make sure the PPPoE client is installed properly...
LOGIN NAME
Enter your Login Name (default root): zhongguo
INTERFACE
Enter the Ethernet interface connected to the ADSL modem
For Solaris, this is likely to be something like /dev/hme0.
For Linux, it will be ethX, where 'X' is a number.
(default eth0):
Do you want the link to come up on demand, or stay up continuously?
If you want it to come up on demand, enter the idle time in seconds
after which the link should be dropped. If you want the link to
stay up permanently, enter 'no' (two letters, lower-case.)