0

I have a network 10.0.0.0/24, a gateway with ip 10.0.0.1. On the gateway there are two interfaces.

eth0        Link encap:Ethernet  HWaddr 08:00:27:a1:24:2d  
            inet addr:10.0.0.1  Bcast:10.0.0.255  Mask:255.255.255.0
            inet6 addr: fe80::a00:27ff:fea1:242d/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:221 errors:0 dropped:0 overruns:0 frame:0
            TX packets:939 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000 
            RX bytes:26698 (26.0 KiB)  TX bytes:65901 (64.3 KiB)

eth1        Link encap:Ethernet  HWaddr 08:00:27:18:75:46  
            inet addr:192.168.56.102  Bcast:192.168.56.255  Mask:255.255.255.0
            inet6 addr: fe80::a00:27ff:fe18:7546/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:898138 errors:0 dropped:0 overruns:0 frame:0
            TX packets:159141 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000 
            RX bytes:1044694113 (996.2 MiB)  TX bytes:9919636 (9.4 MiB)

I want to do routing from eth1 where received traffic to eth0, interface for internal network and vice versa. Gateway do ip forwarding and. I have set this in sysctl.conf:

net.ipv4.ip_forward = 1.

I tried this with iptables but doesn't work:

iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT
iptables -A FORWARD -o eth1 -i eth0 -j ACCEPT
| improve this question | | | | |
  • 1
    Share the gateway's routing table (ip r sh or route -n) plus one of the client's routing tables. Do you have any other active firewall rules? Sharing them might help too. What happens of you ping a host from a client that is not in the client's subnet? – fuero Dec 14 '14 at 13:15
0

Not very sure what you want. I assuming that your eth1 is a gateway for the 192.168.56.0 networks. Please try:

iptables -t nat -I POSTROUTING -s 192.168.56.0/24 -j SNAT --to 10.0.0.1
| improve this answer | | | | |
  • 1
    There's no indication NAT is needed here. Although it may work, it's very likely that it's not the best solution. – Teun Vink Dec 14 '14 at 14:48
  • Agreed, I'm not very sure what he want. – Xcat Dec 14 '14 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.