1.公司内网用户需要通过网关服务器共享上网
2.互联网用户需要访问网站服务器
3.只允许192.168.1 .0/24ping网关和服务器
4.网站服务器和网关服务器均通过SSH来远程管理,为了安全,将SSH默认端口改为12345,只允许192.168.1.10主机SSH网关和服务器,允许互联网SSH内部服务器
1.网关服务器:Centos7 -1
2.企业内网测试机:Centos7 -2
3.网站服务器:Centos7 -3
4.Internet测试机:Centos7 -4
1.添加网卡,并绑定网卡为VMent2仅主机模式
2.配置并确认网关地址
[root@192 network-scripts]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 100.1.1.10 netmask 255.255.255.0 broadcast 100.1.1.255
inet6 fe80::839c:1220:87fc:aef prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:70:78:f5 txqueuelen 1000 (Ethernet)
RX packets 2715 bytes 723845 (706.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 623 bytes 55679 (54.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens36: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.10.1 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::3d7f:4cdc:f7ec:8638 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:70:78:09 txqueuelen 1000 (Ethernet)
RX packets 38 bytes 7923 (7.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 143 bytes 24516 (23.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens37: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.20.1 netmask 255.255.255.0 broadcast 192.168.2.255
inet6 fe80::a6c3:1677:f71d:8e29 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:70:78:ff txqueuelen 1000 (Ethernet)
RX packets 38 bytes 7923 (7.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 138 bytes 23100 (22.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
3.开启路由转发功能
[root@192 network-scripts]# vim /etc/sysctl.conf
...... //省略注释内容
net.ipv4.ip_forward = 1 //添加此条目
[root@192 network-scripts]# sysctl -p //载入sysctl配置文件
net.ipv4.ip_forward = 1
1.绑定网卡为VMent3仅主机模式
2.配置并确认IP地址与网关
[root@192 network-scripts]# ifconfig //查看ip地址及子网掩码
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.10.10 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::839c:1220:87fc:aef prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:90:44:7f txqueuelen 1000 (Ethernet)
RX packets 2647 bytes 190172 (185.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 453 bytes 51940 (50.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@192 network-scripts]# route -n //查看路由信息
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.10.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33
1.先在联网状态下载安装httpd服务
[root@192 ~]# yum install httpd -y
2.绑定网卡为VMent3仅主机模式**
3.配置并确认IP地址与网关
[root@dmz ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.20.20 netmask 255.255.255.0 broadcast 192.168.2.255
inet6 fe80::839c:1220:87fc:aef prefixlen 64 scopeid 0x20<link>
inet6 fe80::791b:db71:8a12:f34 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:de:4a:b8 txqueuelen 1000 (Ethernet)
RX packets 5353 bytes 3513622 (3.3 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1143 bytes 105439 (102.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@dmz ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.20.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33
4.开启网站服务
[root@192 ~]# vim /var/www/html/index.html
[root@192 ~]# cat /var/www/html/index.html
<h2>this is dmz web</h2>
[root@dmz html]# systemctl start httpd
success
[root@dmz ~]# firewall-cmd --add-service=http --zone=dmz --permanent //将防火墙的默认区域改为dmz区域
success
[root@dmz ~]# firewall-cmd --remove-service=ssh --zone=dmz --permanent //添加http服务到dmz区域永久设置中
success
[root@dmz ~]# firewall-cmd --add-icmp-block=echo-request --zone=dmz --permanent //禁止使用ssh进行登录
success
[root@dmz ~]# firewall-cmd --reload //重载防火墙
success
1.先在联网状态下载安装httpd服务
[root@192 ~]# yum install httpd -y
2.绑定网卡为VMent1仅主机模式
3.配置并确认IP地址与网关
[root@192 ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 100.1.1.20 netmask 255.255.255.0 broadcast 100.1.1.255
inet6 fe80::839c:1220:87fc:aef prefixlen 64 scopeid 0x20<link>
inet6 fe80::791b:db71:8a12:f34 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:9e:f9:aa txqueuelen 1000 (Ethernet)
RX packets 6587 bytes 4090863 (3.9 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1266 bytes 105686 (103.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@192 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
100.1.1.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33
4.开启网站服务,并关闭防火墙与增强型安全功能
[root@192 ~]# vim /var/www/html/index.html
[root@192 ~]# cat /var/www/html/index.html
<h2>this is external web</h2>
[root@192 ~]# systemctl stop firewalld.service
[root@192 ~]# setenforce 0
[root@192 ~]# firewall-cmd --set-default-zone=external //将防火墙默认区域改为extemal
success
[root@192 ~]# firewall-cmd --change-interface=ens36 --zone=trusted --permanent //将ens36网卡设为信任区域
The interface is under control of NetworkManager, setting zone to 'trusted'.
success
[root@192 ~]# firewall-cmd --change-interface=ens37 --zone=dmz --permanent //将ens37网卡设为dmz区域
The interface is under control of NetworkManager, setting zone to 'dmz'.
success
[root@192 ~]# firewall-cmd --zone=dmz --remove-service=ssh --permanent //dmz区域内禁止使用ssh登录
success
[root@192 ~]# firewall-cmd --zone=dmz --add-service=http --permanent //dmz区域内添加http服务
success
[root@192 ~]# firewall-cmd --zone=dmz --add-icmp-block=echo-request --permanent //dmz区域内阻塞icmp协议
success
[root@192 ~]# firewall-cmd --zone=external --add-service=http --permanent //在外部区域添加http服务
success
[root@192 ~]# firewall-cmd --reload //重载防火墙
success
[root@192 ~]# firewall-cmd --zone=external --add-forward port=port=80:proto=tcp:toaddr=192.168.2.10 --permanent //设定端口映射
success
[root@192 ~]# firewall-cmd --reload //重载防火墙
success
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。