小编Ghi*_*der的帖子

如何将数据包从网络接口转发到另一个

我的问题是将数据包从我的 LAN eth2 转发到可以访问互联网的 eth1,以允许 eth2 访问互联网,这里是我的配置:

auto eth1
iface eth1 inet static
    address 192.168.3.1
    netmask 255.255.255.0
    network 192.168.3.0
    broadcast 192.168.3.255
    gateway 192.168.3.254

auto eth2
iface eth2 inet static
    address 10.101.26.1
    netmask 255.255.0.0
    network 10.101.0.0
    broadcast 10.101.255.255
Run Code Online (Sandbox Code Playgroud)

iptables 配置:

iptables -A FORWARD -i eth2 -o eth1 -j ACCEPT
iptables -A FORWARD -i eth1 -o eth2 -j ACCEPT
Run Code Online (Sandbox Code Playgroud)

已经在/etc/sysctl.conf 中取消注释net.ipv4.ip forward=1并在/proc/sys/net/ipv4/ip_forward 中写入 1 。

如果我使用连接在 LAN 上且网关为 10.101.26.1 的 PC 进行测试,我无法访问互联网,那么我该如何解决呢?

感谢您的任何帮助!问候

networking linux firewall iptables forwarding

4
推荐指数
1
解决办法
2万
查看次数

标签 统计

firewall ×1

forwarding ×1

iptables ×1

linux ×1

networking ×1