网关服务器的常见用途:
1.企业局域网想要访问外网,可以使用网关服务器上网
2.可以一个网卡连接公网,一个网卡连接局域网交换机,让网关服务器做路由器使用

Windows 平台

服务端平台:Windows 7(服务端必须有两张网卡) 客户端平台:Windows 10
外网IP:192.168.111.0/24 内网IP:192.168.222.0/24

1. 外网适配器打开共享.

Windows 或 Linux平台搭建网关服务器

这里有一点要注意,外网打开允许其他用户连接后,内网的IP地址会自动改变,这时候得手动修改一下内网适配器的IP地址.

2. 内网机器设置

Windows 或 Linux平台搭建网关服务器

已经可以正常上网Windows 或 Linux平台搭建网关服务器

注意:
内网适配器的固定IP不要填写网关,否则会导致路由混乱.

在Linux平台搭建(使用iptables)

这里服务端平台用Centos 7 1804版本,客户端用的是Win7
外网IP:192.168.111.0/24 内网IP:192.168.222.0/24

1. 关闭firewalld,打开iptables服务

systemctl stop firewalld
systemctl mask firewalld
安装iptables-services
yum install iptables-service
设置开机启动防火墙
systemctl enable iptables

2. 开启内核转发

vim /etc/sysctl.conf
添加一条net.ipv4.ip_forward = 1

3. 配置iptables

iptables -t nat -A POSTROUTING -s 192.168.222.0/24 -j MASQUERADE

4.保存&重启iptables

service iptables save
service iptables restart

相关文章:

  • 2022-02-08
  • 2021-11-08
猜你喜欢
  • 2021-11-14
  • 2022-12-23
  • 2021-05-31
  • 2021-04-01
  • 2021-06-03
  • 2021-11-30
相关资源
相似解决方案