全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 1071|回复: 3

[美国VPS] 求助关于内网转发

[复制链接]
发表于 2023-8-18 16:57:02 | 显示全部楼层 |阅读模式
有个内网集群01可以上外网比如ping通百度,02是个计算只有内网,能ping通01,我该怎么弄让02也可以ping通百度,来个大佬支个招

看下这个脚本哪里需要改一下
#!/bin/bash
# setup NAT gate service

# Run this on master node,
# Point the default gateway to master IP address on all slave nodes
# All slave nodes can access internet.
# You are happy to run yum -y update, etc.

## LAN, private interface
## LANNET, private network
## WAN, public interface

## set interface name first.

LAN="ens81"
WAN="eno1"

LANNET="10.0.0.0/24"

### Do not edit the following contents.

export LAN WAN LANNET

### Flush the original rules
/sbin/iptables -F
/sbin/iptables -X
/sbin/iptables -Z
/sbin/iptables -F -t nat
/sbin/iptables -X -t nat
/sbin/iptables -Z -t nat

### load modules
modprobe ip_tables         > /dev/null 2>&1
modprobe iptable_nat       > /dev/null 2>&1
modprobe ip_nat_ftp       > /dev/null 2>&1
modprobe ip_nat_irc       > /dev/null 2>&1
modprobe ipt_mark       > /dev/null 2>&1
modprobe ip_conntrack       > /dev/null 2>&1
modprobe ip_conntrack_ftp   > /dev/null 2>&1
modprobe ip_conntrack_irc   > /dev/null 2>&1
modprobe ipt_MASQUERADE   > /dev/null 2>&1

### enable the client to use 扶墙 service
modprobe ip_nat_pptp > /dev/null 2>&1
modprobe ip_nat_proto_gre  > /dev/null 2>&1
modprobe ip_conntrack_pptp  > /dev/null 2>&1
modprobe ip_nat_ftp  > /dev/null 2>&1


# Set Default Rules
/sbin/iptables -P INPUT        ACCEPT
/sbin/iptables -P OUTPUT  ACCEPT
/sbin/iptables -P FORWARD        ACCEPT
/sbin/iptables -t nat -P PREROUTING  ACCEPT
/sbin/iptables -t nat -P POSTROUTING ACCEPT
/sbin/iptables -t nat -P OUTPUT      ACCEPT


### Accept ping test
iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
iptables -A OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT


### For NAT Gateway
# Starting NAT Server
echo "1" > /proc/sys/net/ipv4/ip_forward

# Stop NAT immediately
#echo "0" > /proc/sys/net/ipv4/ip_forward

# POSTROUTE  NAT Client
/sbin/iptables -t nat -A POSTROUTING -s $LANNET -o $WAN -j MASQUERADE


# the following two lines Enable iptables work in High Efficiency
/sbin/iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

# 5 may be useful for some sites,
#        configure the MTU value.
iptables -A FORWARD -p tcp -m tcp --tcp-flags SYN,RST SYN -m tcpmss \
          --mss 1400:1536 -j TCPMSS --clamp-mss-to-pmtu

 楼主| 发表于 2023-8-18 17:05:16 | 显示全部楼层
 楼主| 发表于 2023-8-18 17:18:29 | 显示全部楼层
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-4-29 17:23 , Processed in 0.060714 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表