A
A
Alexey Andrianov2014-10-02 14:58:50
iptables
Alexey Andrianov, 2014-10-02 14:58:50

Ubuntu Server + NAT + PPPoE + port forwarding how to organize?

Dear community, burning PPC.
I used to do it under Firestarter, but now I have to do it under pure iptables
Task:
there are 4 interfaces:

lo        Link encap:Локальная петля (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:16505 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16505 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1141391 (1.1 MB)  TX bytes:1141391 (1.1 MB)

p1p1      Link encap:Ethernet  HWaddr 10:fe:ed:05:2c:1f  
          inet addr:192.168.0.2  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::12fe:edff:fe05:2c1f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8436443 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8401425 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:877453127 (877.4 MB)  TX bytes:723550148 (723.5 MB)

p2p1      Link encap:Ethernet  HWaddr bc:ee:7b:88:c6:5f  
          inet addr:10.10.2.1  Bcast:10.10.2.255  Mask:255.255.255.0
          inet6 addr: fe80::beee:7bff:fe88:c65f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8220307 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7593191 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:633156402 (633.1 MB)  TX bytes:692474991 (692.4 MB)

ppp0      Link encap:Протокол PPP (Point-to-Point Protocol)  
          inet addr:194.50.255.100  P-t-P:194.50.255.1  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1492  Metric:1
          RX packets:14970 errors:0 dropped:0 overruns:0 frame:0
          TX packets:18925 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3 
          RX bytes:3504655 (3.5 MB)  TX bytes:7238200 (7.2 MB)

How to write iptables correctly?
Wrote:
sysctl -w net.ipv4.ip_forward="1"
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
iptables -t nat -A PREROUTING -p tcp -d 194.50.255.100 --dport 80 -j DNAT --to-destination 10.10.2.2:80
iptables -t nat -A POSTROUTING -p tcp --dst 10.10.2.2 --dport 80 -j SNAT --to-source 195.18.48.76

Pings go, but in the locale 10.10.2.0/24 TimViewer does not work, the feeling that the packets go in one direction from the outside.
The same situation with forwarding 10.10.2.2 if on port 80.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Cool Admin, 2014-10-03
@ifaustrue

What do you have in other chains? obviously in the input and forward problem.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question