本帖最后由 ffb 于 2021-7-18 12:05 编辑
以下为interfaces配置文件,我开了一个win2016nat小鸡,然后服务器的IP绑定了个域名,但是nat不能访问这个域名,自己电脑访问这个域名是正常的。想问问以下配置文件还有那儿需要修改一下才能让nat小鸡可以访问这个域名?? auto lo iface lo inet loopback
iface enp1s0 inet manual
auto vmbr0 iface vmbr0 inet static address 公网IP地址/32 gateway 100.64.35.133 bridge-ports enp1s0 bridge-stp off bridge-fd 0
iface vmbr0 inet6 static address IPV6/64 gateway IPV6网关
auto vmbr2 iface vmbr2 inet static address 10.0.0.254/24 bridge-ports none bridge-stp off bridge-fd 0 post-up echo 1 > /proc/sys/net/ipv4/ip_forward post-up iptables -t nat -A POSTROUTING -s ‘10.0.0.0/24’ -o vmbr0 -j MASQUERADE post-down iptables -t nat -D POSTROUTING -s ‘10.0.0.0/24’ -o vmbr0 -j MASQUERADE post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp –dport 8888 -j DNAT –to 10.0.0.102:8888 post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp –dport 8888 -j DNAT –to 10.0.0.102:8888 post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp –dport 3389 -j DNAT –to 10.0.0.102:3389 post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp –dport 3389 -j DNAT –to 10.0.0.102:3389 post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp –dport 10022 -j DNAT –to 10.0.0.102:22 post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp –dport 10022 -j DNAT –to 10.0.0.102:22 post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp –dport 80 -j DNAT –to 10.0.0.102:80 post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp –dport 80 -j DNAT –to 10.0.0.102:80 post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp –dport 443 -j DNAT –to 10.0.0.102:443 post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp –dport 443 -j DNAT –to 10.0.0.102:443 以下为新增,增加回流,这样就可以在nat通过公网IP访问服务: post-up iptables -t nat -A PREROUTING -s 10.0.0.0/24 -d 公网/32 -p tcp -m tcp –dport 80 -j DNAT –to-destination 10.0.0.102 post-up iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -d 10.0.0.0/24 -j SNAT –to-source 10.0.0.254 post-down iptables -t nat -A PREROUTING -s 10.0.0.0/24 -d 公网/32 -p tcp -m tcp –dport 80 -j DNAT –to-destination 10.0.0.102 post-down iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -d 10.0.0.102 -j SNAT –to-source 10.0.0.254 说明: PREROUTING -s 私网网段 -d 公网IP -j DNAT –to-destination 私网服务器地址 POSTROUTING -s 私网网段 -d 私网服务器地址 -j SNAT –to-source 私网网关 |