如何在不同的ISP中使用相同的静态IP地址? [英] How to use the same static IP address with different ISPs?

查看:163
本文介绍了如何在不同的ISP中使用相同的静态IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在AWS上配置了数据库服务器,我想限制仅通过计算机IP访问它.

I have a database server configured on AWS and I want to restrict access to it only from my computer's IP.

问题在于IP地址是由ISP动态分配的,每次从本地网络切换到其他网络时,在从计算机访问服务器之前,我都需要手动将IP地址列入白名单.

The problem is as IP addresses get assigned dynamically by the ISPs, I manually need to whitelist my IP address before accessing the server from my computer, everytime I switch from my home network to some other network.

我已经能够为机器设置一个静态IP地址,但是当我尝试将ISP从本地宽带更改为移动互联网的热点或与宽带不同的另一个网络时,连接似乎失败.有什么方法可以让我的机器在使用不同的ISP时使用相同的静态IP?

I have been able to set a static IP address for my machine, but when I try to change my ISP from local broadband to mobile internet's hot-spot or to another network different from my broadband, the connection seems to fail. Is there any way to make my machine use the same static IP while using different ISPs ?

推荐答案

这是我使用的脚本:

IP=`curl -s http://whatismyip.akamai.com/`
aws ec2 authorize-security-group-ingress --group-name GROUP-NAME --protocol tcp --port 22   --cidr $IP/32 --output text

在此示例中,它正在将我当前的IP地址添加到安全组以与SSH一起使用(端口22).您可以根据需要对其进行修改.

In this example, it is adding my current IP address to the security group for use with SSH (port 22). You can modify it for your needs.

请注意,安全组规则数量最大,因此达到限制后,您需要清空".

Please note that there is a maximum number of security group rules, so you will need to "empty it out" after you've hit the limit.

这篇关于如何在不同的ISP中使用相同的静态IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆