【运维知识进阶篇】用阿里云配置NAT网关配置

本篇文章教大家NAT网关如何配置,NAT网关配置相当于路由器,如果服务器ECS没有公网IP只有私网IP,也可以依靠NAT去上网。话不多说,直接开始!

购买NAT网关并配置弹性公网IP

e15cb529c5b44b8b92675a215417ed91.png

63f0b96142dc42acbc294d5428a68543.png3cb6ce5be5174b4d90ef32a6fea541a8.png立即购买,确认订单,签署并下单,资源创建完毕后进入控制台。 

32c8d7d0db1e49b9845fb239dc776692.png

889029d1d9ee44c798a3656ddbb2ba98.png

 配置DNAT管理

1a35fc0652374ccdbdaa1182454a8a1f.png

8e5db04a9a0d48b1934599e274a2fa1b.png

fd4911ff906a49b2a36a605b9db10690.png

66e3aacdab174a1cb5656e322db76ca9.png

 配置好后,我们可以通过xshell连通,但是依旧无法上网

[c:\~]$ ssh 8.130.74.161 6666


Connecting to 8.130.74.161:6666...
Connection established.
To escape to local shell, press Ctrl+Alt+].

Last login: Tue Apr 25 22:29:54 2023 from 123.112.19.205

Welcome to Alibaba Cloud Elastic Compute Service !

[root@web02 ~]# ping www.baidu.com
PING www.a.shifen.com (110.242.68.4) 56(84) bytes of data.

SNAT配置

dfb97c73703b49ada2260d65d7a20f0b.png

5d99a7c16059407d878adb82428f1dc4.png

 创建好后,web1和web2皆可联网

[root@web02 ~]# ping www.baidu.com
PING www.a.shifen.com (110.242.68.3) 56(84) bytes of data.
64 bytes from 110.242.68.3 (110.242.68.3): icmp_seq=1 ttl=49 time=20.1 ms
64 bytes from 110.242.68.3 (110.242.68.3): icmp_seq=2 ttl=49 time=20.0 ms
^C
--- www.a.shifen.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 20.010/20.081/20.153/0.158 ms

[root@web01 ~]# ping www.koten.vip
PING www.koten.vip (101.200.45.134) 56(84) bytes of data.
64 bytes from 101.200.45.134 (101.200.45.134): icmp_seq=1 ttl=120 time=9.13 ms
64 bytes from 101.200.45.134 (101.200.45.134): icmp_seq=2 ttl=120 time=8.74 ms
^C
--- www.koten.vip ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 8.743/8.937/9.131/0.194 ms

大功告成! 


我是koten,10年运维经验,持续分享运维干货,感谢大家的阅读和关注!

猜你喜欢

转载自blog.csdn.net/qq_37510195/article/details/130379209
今日推荐