1、linux实验手册LAB1=网络的基本配置涉及的知识点:1. 基本配置文件/etc/hosts:是将IP地址和主机名联系起来的简单文本文件。格式:IP地址 全限定主机名 别名举例:192.168.0.2 wanghui说明:将IP地址映射到,并且分配一个备用主机名wanghui。实验拓扑具体实验步骤:编辑HOSTS文件:rootb root# vi /etc/hosts在HOST中添加一行:192.168.1.202 用PING进行验证:rootb root# ping 192.168.1.202PING 192.168.1.202 (192.168.1.202) 56(84) bytes o
2、f data.64 bytes from 192.168.1.202: icmp_seq=9 ttl=128 time=0.290 ms64 bytes from 192.168.1.202: icmp_seq=10 ttl=128 time=0.293 msPING域名验证成功:rootb 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 ms64 bytes from (192.168.1.202): icmp_s
3、eq=2 ttl=128 time=0.297 msLAB2=如何修改主机的名字?涉及的知识点:/etc/sysconfig/network:网络配置信息,系统启动时会引导这个文件。内容:NETWORKING=YES|NOYES表示需要配置网络,NO表示不需要配置网络;HOSTNAME=homename主机的全限定域名;GATEWAY=gw-ip网络网关的IP地址;GATEWAYDEV=gw-dev网络设备的名称(例如eth0或者IP地址);NISDOMAIN=dom-name表示NIS域(如果有的话)。具体实验步骤:编辑network文件:rootb root# vi /etc/syscon
4、fig/network在HOSTNAME中把主机名修改为NETWORKING=yesHOSTNAME=重启LINUXrootb root# init 6重新登陆linux中验证主机名rootb root# hostnameLAB3=如何配置LINUX的网卡1、涉及的知识点可执行脚本和命令/etc/rc.d/init.d/network start|stop|restart|reload|status系统启动时的初始化脚本程序。/etc/sysconfig/network-scripts/ifcfg-interface-name:网卡配置文件。内容:DEVICE=物理设备名IPADDR=IP地址
5、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 dynam
6、ic说明:启动dhcp举例:ifconfig eth0 down|up说明:启动或关闭网卡netconfig:通过通行界面配置网络。具体步骤:方法1:修改ifcfg-interface-name文件rootb root# vi /etc/sysconfig/network-scripts/ifcfg-eth0修改好IP地址、网关等信息DEVICE=eth0ONBOOT=yesBOOTPROTO=staticIPADDR=192.168.1.2NETMASK=255.255.255.0GATEWAY=192.168.1.2使配置生效rootb root# /etc/rc.d/init.d/net
7、work restartShutting down interface eth0: OK Shutting down loopback interface: OK Setting network parameters: OK Bringing up loopback interface: OK Bringing up interface eth0: OK rootb root# service network restart验证是否修改成功rootb root# ifconfigeth0 Link encap:Ethernet HWaddr 00:0C:29:FC:9A:A6 inet add
8、r: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) Interr
9、upt:10 Base address:0x1080lo 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:500
10、22 (48.8 Kb)方法2:使用netconfig不详细叙述方法3:使用Ifconfig命令把主机的IP地址设置为192.168.1.250rootb root# ifconfig eth0 192.168.1.250 netmask 255.255.255.0验证是否修改成功rootb root# ifconfigeth0 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 MULTI
11、CAST 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:0x1080LAB4=如何禁用和启动网卡?LAB5=如何在LINUX中上网LAB6=在linux中采用adsl拨号上网
12、配置拨号设置Last login: Sat Jul 8 11:04:05 2006rootns root# adsl-setupWelcome to the ADSL client setup. First, I will run some checks onyour system to make sure the PPPoE client is installed properly.LOGIN NAMEEnter your Login Name (default root): zhongguoINTERFACEEnter the Ethernet interface connected to
13、 the ADSL modemFor 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 secondsafter which the link should
14、be dropped. If you want the link tostay up permanently, enter no (two letters, lower-case.)NOTE: Demand-activated links do not interact well with dynamic IPaddresses. You may have some problems with demand-activated links.Enter the demand value (default no): DNSPlease enter the IP address of your IS
15、Ps primary DNS server.If your ISP claims that the server will provide dynamic DNS addresses,enter server (all lower-case) here.If you just press enter, I will assume you know what you aredoing and not modify your DNS setup.Enter the DNS information here: 202.106.0.20Please enter the IP address of yo
16、ur ISPs secondary DNS server.If you just press enter, I will assume there is only one DNS server.Enter the secondary DNS server address here: PASSWORDPlease enter your Password: Please re-enter your Password: USERCTRLPlease enter yes (two letters, lower-case.) if you want to allownormal user to star
17、t or stop DSL connection (default yes): FIREWALLINGPlease choose the firewall rules to use. Note that these rules arevery basic. You are strongly encouraged to use a more sophisticatedfirewall setup; however, these will provide basic security. If youare running any servers on your machine, you must
18、choose NONE andset up firewalling yourself. Otherwise, the firewall rules will denyaccess to all standard servers like Web, e-mail, ftp, etc. If youare using SSH, the rules will block outgoing SSH connections whichallocate a privileged source port.The firewall choices are:0 - NONE: This script will
19、not set any firewall rules. You are responsible for ensuring the security of your machine. You are STRONGLY recommended to use some kind of firewall rules.1 - STANDALONE: Appropriate for a basic stand-alone web-surfing workstation2 - MASQUERADE: Appropriate for a machine acting as an Internet gatewa
20、y for a LANChoose a type of firewall (0-2): 2Start this connection at boot timeDo you want to start this connection at boot time?Please enter no or yes (default no):* Summary of what you entered *Ethernet Interface: eth0User name: zhongguoActivate-on-demand: NoPrimary DNS: 202.106.0.20Firewalling: M
21、ASQUERADEUser Control: yesAccept these settings and adjust configuration files (y/n)? yAdjusting /etc/sysconfig/network-scripts/ifcfg-ppp0Adjusting /etc/resolv.conf (But first backing it up to /etc/resolv.conf.bak)Adjusting /etc/ppp/chap-secrets and /etc/ppp/pap-secrets (But first backing it up to /
22、etc/ppp/chap-secrets.bak) (But first backing it up to /etc/ppp/pap-secrets.bak)Congratulations, it should be all set up!Type /sbin/ifup ppp0 to bring up your xDSL link and /sbin/ifdown ppp0to bring it down.Type /sbin/adsl-status /etc/sysconfig/network-scripts/ifcfg-ppp0to see the link status.启动拨号roo
23、tns root# adsl-start验证结果rootns root# adsl-statusNote: You have enabled demand-connection; adsl-status may be inaccurate.LAB7=搭建LINUX的路由器具体步骤主机A为该机器设置好两个网卡,配置好IP。rootredhatns root# ifconfigeth0 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 U
24、P BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 eth1 Link encap:Ethernet HWaddr 00:0C:29:FC:9A:B0 inet addr:172.168.1.2 Bcast:172.168.255.255 Mask:255.255.255.0设置好IP的转发功能rootredhatns ipv4# echo 1 /proc/sys/net/ipv4/ip_forward用netconfig给主机B设置好IP地址并设置好网关地址172.168.1.2rootns root# ifconfigeth0 Link enca
25、p:Ethernet HWaddr 00:0C:29:7C:34:8D inet addr:172.168.1.3 Bcast:192.168.1.255 Mask:255.255.255.0用netconfig给主机C设置好IP地址并设置好网关地址192.168.1.2rootns root# ifconfigeth0 Link encap:Ethernet HWaddr 00:0C:29:7C:34:8D inet addr:192.168.1.3 Bcast:192.168.1.255 Mask:255.255.255.0验证结果rootns root# ping 172.168.1.3
26、PING 172.168.1.3 (172.168.1.3) 56(84) bytes of data.64 bytes from 172.168.1.3: icmp_seq=1 ttl=63 time=1.88 ms64 bytes from 172.168.1.3: icmp_seq=2 ttl=63 time=1.42 msDNS服务器LAB=创建主DNS服务器案例描述:建立主域名服务器:(请写出实验过程)a) 两台主机ip分别为192.168.1.1和192.168.1.2;主机名分别为和(windows系统即可)b) 名称服务器名:c) 添加两个正向区域,一个.一个;反向区域不做强制
27、要求d) 正向解析文件添加二个A记录hx和bmail,一个CNAME记录wwwe) 正向解析文件添加二个A记录hd和amail,一个CNAME记录wwwf) 两个正向解析文件中分别添加各自域的MX记录g) 两台主机分别PING对方的域名,并在linux系统上分别用nslookup、dig、host测试。具体步骤rootns root# ifconfigeth0 Link encap:Ethernet HWaddr 00:0C:29:52:3E:8F inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0rootns root#
28、vi /etc/named.conf在include /etc/rndc.key;后添加以下内容zone IN type master; file ; allow-update none; ;zone IN type master; file ; allow-update none; ;/etc/named.conf 46L, 938C written rootns root# cp /var/named/named.local /var/named/rootns root# vi /etc/sysconfig/networkNETWORKING=yesHOSTNAME= rootns roo
29、t# init 6rootns root# hostnamerootns root# vi /var/named/$TTL 86400 IN SOA . . ( 1997022700 ; Serial 28800 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Minimum IN NS . IN MX 0 ns IN A 192.168.1.1bmail IN CNAME nswww IN CNAME ns/var/named/ 12L, 529C written rootns root# cp /var/named/ /var/named/rootns root# vi /var/named/$TTL 86400 IN SOA . . ( 1997022700 ; Serial 28800 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Minimum IN NS . IN MX 0
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1