我正在尝试添加行
-A POSTROUTING -i ppp0 -j MASQUERADE
到我的 IPTables 以允许 VPN 访问整个内部和外部网络(eth0 和 eth1),但是当我尝试应用它时,它会弹出错误消息:
iptables-restore v1.4.18: Can't use -i with POSTROUTING
有没有办法允许从 ppp0 访问 eth0 和 eth1,而不允许从 eth0 访问 eth1?有没有我还没想到的替代方案?这是我的 ifconfig:
david@Mathusala ~ $ ifconfig
eth0 Link encap:Ethernet HWaddr 6c:f0:49:57:03:fc
inet addr:50.139.49.92 Bcast:255.255.255.255 Mask:255.255.252.0
inet6 addr: fe80::6ef0:49ff:fe57:3fc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:42542255 errors:0 dropped:0 overruns:0 frame:0
TX packets:19116720 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:38763455707 (38.7 GB) TX bytes:3931758927 (3.9 GB)
eth1 Link encap:Ethernet HWaddr 6c:f0:49:57:03:ec
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::6ef0:49ff:fe57:3ec/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:34175606 errors:0 dropped:2 overruns:0 frame:0
TX packets:63558373 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7313801292 (7.3 GB) TX bytes:83294618259 (83.2 GB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:1033589 errors:0 dropped:0 overruns:0 frame:0
TX packets:1033589 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:4320636783 (4.3 GB) TX bytes:4320636783 (4.3 GB)
ppp0 Link encap:Point-to-Point Protocol
inet addr:192.168.1.1 P-t-P:192.168.1.234 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1486 Metric:1
RX packets:13 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:512 (512.0 B) TX bytes:96 (96.0 B)
谢谢你!
答案1
错误是正确的;您无法在POSTROUTING通过输入界面进行筛选。
尝试一下
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE