发布时间:2022年11月19日 修改时间:2024年05月04日 已有 62103 人围观
如何在 EdgeRouter 的端口上添加静态公网 IP 地址
Internet 服务提供商(ISP)可以通过多种方式为您提供公网 IP 地址,例如:
Static
ISP 为您提供 IP 范围,并要求您手动添加地址和网关。DHCP
ISP 通过 DHCP 自动分配地址。PPPoE
ISP 要求您手动添加 PPPoE 接口和身份验证凭据。如果您使用的是 ISP 为您提供静态 IP 地址,则该信息可能类似于:
网络地址: 203.0.113.0
广播地址: 203.0.113.7
子网掩码: 255.255.255.248
网关地址: 203.0.113.6
DNS 服务器: 192.0.2.1 - 192.0.2.2
EdgeRouter 要求 IP 地址以 CIDR 格式写入。 这意味着需要将 ISP 提供的子网掩码(255.255.255.248)转换为路由前缀。 从子网掩码转换为 CIDR 前缀的一种简单方法是使用 IPv4 子网计算器。
在此示例中,当前缀为 /29 时,可以添加到 EdgeRouter 的可用 IP 地址为 203.0.113.1-203.0.113.5 。
GUI: 访问 EdgeRouter Web UI。
1.导航到 Dashboard 选项卡,然后将 IP 地址分配给 WAN 接口。
Dashboard > Eth0 > Actions > Config
Address: Manually define IP address
IP: 203.0.113.1/29
+ 添加 IP
Address: Manually define IP address
IP: 203.0.113.2/29
IP: 203.0.113.3/29
IP: 203.0.113.4/29
IP: 203.0.113.5/29
2.导航到 Web UI 左下方的系统选项卡,以添加默认网关和 DNS 服务器。
System > Name Server
System name server: 192.0.2.1
+ 添加新地址
System name server: 192.0.2.2
System > Gateway
System gateway address: 203.0.113.6
用户提示: 您也可以在路由选项卡下配置默认网关。
CLI: 访问 EdgeRouter 命令行界面(CLI)。
1.进入配置模式。
configure
2.从 WAN 接口清除现有 IP 地址配置。
delete interfaces ethernet eth0 address
3.将 IP 地址分配给 WAN 接口。
set interfaces ethernet eth0 address 203.0.113.1/29
set interfaces ethernet eth0 address 203.0.113.2/29
set interfaces ethernet eth0 address 203.0.113.3/29
set interfaces ethernet eth0 address 203.0.113.4/29
set interfaces ethernet eth0 address 203.0.113.5/29
4.添加默认网关地址。
set system gateway-address 203.0.113.6
用户提示: 您还可以使用 set protocols static route0.0.0.0/0 next-hop <gateway-address>
命令配置默认网关。
5.添加 DNS 服务器。
set system name-server 192.0.2.1
set system name-server 192.0.2.2
6.提交更改并保存配置。
commit ; save