步骤
实现此案例需要按照如下步骤进行。
步骤一:根据以下要求查看接口信息
分别查看物理网卡、lo回环接口的信息。
命令操作如下所示:
[root@localhost 桌面]# ifconfig eth0 //查看eth0网卡信息
eth0 Link encap:Ethernet HWaddr 00:0C:29:0D:06:9A
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe0d:69a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:10596 errors:0 dropped:0 overruns:0 frame:0
TX packets:74 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:757148 (739.4 KiB) TX bytes:10154 (9.9 KiB)
[root@localhost 桌面]# ifconfig lo //查看lo回环接口信息
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:80 errors:0 dropped:0 overruns:0 frame:0
TX packets:80 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:6328 (6.1 KiB) TX bytes:6328 (6.1 KiB)
[root@localhost 桌面]#
列出所有的网络接口,命令操作如下所示:
[root@localhost 桌面]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:0C:29:0D:06:9A
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe0d:69a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:16800 errors:0 dropped:0 overruns:0 frame:0
TX packets:74 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1201546 (1.1 MiB) TX bytes:10154 (9.9 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:80 errors:0 dropped:0 overruns:0 frame:0
TX packets:80 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:6328 (6.1 KiB) TX bytes:6328 (6.1 KiB)
[root@localhost 桌面]#
步骤二:ping一下网关地址,然后查看ARP缓存表
分析: 利用dhclient命令来获取网关与IP地址。
命令操作如下所示:
[root@localhost 桌面]# dhclient –r //释放现有IP地址
[root@localhost 桌面]# dhclient //从新获取
[root@localhost 桌面]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:0D:06:9A
inet addr:192.168.30.124 Bcast:192.168.30.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe0d:69a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:25598 errors:0 dropped:0 overruns:0 frame:0
TX packets:98 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1811539 (1.7 MiB) TX bytes:13766 (13.4 KiB)
[root@localhost 桌面]# route –n //查看路由表
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.30.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 192.168.30.2 0.0.0.0 UG 0 0 0 eth0
[root@localhost 桌面]# ping 192.168.30.2 //与网关通信
PING 192.168.30.2 (192.168.30.2) 56(84) bytes of data.
64 bytes from 192.168.30.2: icmp_seq=1 ttl=64 time=50.4 ms
64 bytes from 192.168.30.2: icmp_seq=2 ttl=64 time=83.3 ms
64 bytes from 192.168.30.2: icmp_seq=3 ttl=64 time=5.55 ms
^C //按ctrl+c结束
--- 192.168.30.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2374ms
rtt min/avg/max/mdev = 5.557/46.480/83.388/31.900 ms
[root@localhost 桌面]# arp –an //查看ARP缓存表
? (192.168.30.2) at 50:bd:5f:35:f7:b2 [ether] on eth0
[root@localhost 桌面]#
步骤三:查看本机的路由表
命令操作如下所示:
[root@localhost 桌面]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.30.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 192.168.30.2 0.0.0.0 UG 0 0 0 eth0
[root@localhost 桌面]#
步骤四:开启临时服务rsync
查询rsync服务的端口号(/etc/services )。
命令操作如下所示:
[root@localhost 桌面]# rpm -q rsync //查询本机是否安装rsync
rsync-3.0.6-9.el6_4.1.x86_64
[root@localhost 桌面]# rpm -q xinetd //查询本机是否安装xinetd
xinetd-2.3.14-39.el6_4.x86_64
[root@localhost 桌面]# ls /etc/xinetd.d/rsync
/etc/xinetd.d/rsync
[root@localhost 桌面]#
[root@localhost 桌面]# grep disable /etc/xinetd.d/rsync
disable = yes
[root@localhost 桌面]# chkconfig rsync on //将yes改成no
[root@localhost 桌面]# grep disable /etc/xinetd.d/rsync
disable = no
[root@localhost 桌面]# /etc/init.d/xinetd restart
停止 xinetd: [失败]
正在启动 xinetd: [确定]
[root@localhost 桌面]# grep rsync /etc/services
rsync 873/tcp # rsync
rsync 873/udp # rsync
.. ..
利用netstat命令查看系统是否在监听此端口。
命令操作如下所示:
[root@localhost 桌面]# netstat -anptu | grep 873
tcp 0 0 :::873 :::* LISTEN 3186/xinetd
[root@localhost 桌面]#