三臺主機,一臺路由器
win10 -1 :綁定VMnet1網卡
win10-2:綁定VMnet2網卡
linux:綁定VMnet8網卡做爲測試
f0/0:192.168.1.1/24
f1/0:192.168.2.1/24
f10/1:192.168.100.1/24html2.配置linux服務器,安裝兩個服務VSFTPD,HTTPD
[root@localhost ~]# yum install vsftpd -y 已加載插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.cn99.com * updates: mirrors.cn99.com 正在解決依賴關係 --> 正在檢查事務 ---> 軟件包 vsftpd.x86_64.0.3.0.2-25.el7 將被 安裝 --> 解決依賴關係完成 [root@localhost ~]# yum install httpd -y 已加載插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.cn99.com * updates: mirrors.cn99.com 正在解決依賴關係 --> 正在檢查事務
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=static DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens33 UUID=849aa04e-1874-490f-8cb0-b2fde4b9a6f8 DEVICE=ens33 ONBOOT=yes IPADDR=192.168.100.100 NETMASK=255.255.255.0 GATEWAY=192.168.100.1 [root@localhost ~]# systemctl restart network 重啓linux服務器
R1#conf t R1(config)#int f0/0 R1(config-if)#ip add 192.168.1.1 255.255.255.0 R1(config-if)#no shut R1(config-if)#int f0/1 R1(config-if)#ip add 192.168.100.1 255.255.255.0 R1(config-if)#no shut R1(config-if)#int f1/0 R1(config-if)#ip add 192.168.2.1 255.255.255.0 R1(config-if)#no shut R1(config-if)#ex R1(config)#do show ip route Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route o - ODR, P - periodic downloaded static route Gateway of last resort is not set C 192.168.1.0/24 is directly connected, FastEthernet0/0 C 192.168.2.0/24 is directly connected, FastEthernet1/0 C 192.168.100.0/24 is directly connected, FastEthernet0/1
C:\Users\CHEN>ping 192.168.1.2 正在 Ping 192.168.1.2 具備 32 字節的數據: 來自 192.168.1.2 的回覆: 字節=32 時間=19ms TTL=127 來自 192.168.1.2 的回覆: 字節=32 時間=18ms TTL=127 來自 192.168.1.2 的回覆: 字節=32 時間=14ms TTL=127 來自 192.168.1.2 的回覆: 字節=32 時間=15ms TTL=127
root@localhost chen]# systemctl stop firewalld.service root@localhost chen]# setenforce 0 [root@localhost chen]# cd /var/www/html [root@localhost html]# vim index.html <h1>this is test web</h1> [root@localhost html]# ls index.html [root@localhost html]# systemctl start httpd [root@localhost html]# systemctl start vsftpd [root@localhost html]# cd /var/ftp [root@localhost ftp]# ls pub [root@localhost ftp]# echo "this is ftp" > ftp.txt [root@localhost ftp]# ls ftp.txt pub [root@localhost html]# netstat -nuap | egrep '(21|80)' udp 0 0 192.168.122.1:53 0.0.0.0:* 1380/dnsmasq udp 0 0 0.0.0.0:67 0.0.0.0:* 1380/dnsmasq
R1#conf t R1(config)#access-list 100 permit tcp host 192.168.1.2 host 192.168.100.100 eq www //擴展的序列號100-199,容許tcp協議,固定地址192.168.1.2去訪問 192.168.100.100 後面跟端口號80也能夠是名字 R1(config)#do show access-list //查看訪問控制列表 Extended IP access list 100 10 permit tcp host 192.168.1.2 host 192.168.100.100 eq www R1(config)#access-list 100 deny ip host 192.168.1.2 host 192.168.100.100 R1(config)#do show access-list Extended IP access list 100 10 permit tcp host 192.168.1.2 host 192.168.100.100 eq www 20 deny ip host 192.168.1.2 host 192.168.100.100 R1(config)#access-list 100 permit ip host 192.168.1.2 192.168.2.0 0.0.0.255 R1(config)#do show access-list Extended IP access list 100 10 permit tcp host 192.168.1.2 host 192.168.100.100 eq www 20 deny ip host 192.168.1.2 host 192.168.100.100 30 permit ip host 192.168.1.2 192.168.2.0 0.0.0.255 R1(config-if)#ip access-group 100 in //應用在接口,離限制方最近的端口,是入口方向。