You are not logged in.

#1 2011-08-15 09:58:21

Sadface
Member
From: Germany
Registered: 2009-12-09
Posts: 47

[SOLVED] Setting up NAT for a secondary network

Countless guides on iptables have failed to help me with this problem.. I'm trying to set up a NAT on this box which
is connected to the wired home network on 192.168.2.0/24 (eth0) and a wireless Ad-Hoc network on
10.0.0.0/24 (bat0 - B.A.T.M.A.N routing protocol).

This machine is statically assigned to 192.168.2.109 and I'm trying to MASQUERADE/SNAT packets from the
Ad-Hoc to appear to originate from this machine. The 192.168.2.0/24 network itself is NAT'd to the internet
aswell, so basically a NAT within a NAT.

A little graphical helper:

[ Internet ] - - - - - - [ Router ] - - - - - - [ This ] o o o o o o o o [ Ad-Hoc ]

This is my iptables.conf:

# Generated by iptables-save v1.4.12 on Mon Aug 15 12:52:13 2011
*mangle
:PREROUTING ACCEPT [4585:1017080]
:INPUT ACCEPT [4585:1017080]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [4478:581526]
:POSTROUTING ACCEPT [4498:584466]
COMMIT
# Completed on Mon Aug 15 12:52:13 2011
# Generated by iptables-save v1.4.12 on Mon Aug 15 12:52:13 2011
*filter
:INPUT ACCEPT [4585:1017080]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [4478:581526]
COMMIT
# Completed on Mon Aug 15 12:52:13 2011
# Generated by iptables-save v1.4.12 on Mon Aug 15 12:52:13 2011
*nat
:PREROUTING ACCEPT [8:1360]
:INPUT ACCEPT [8:1360]
:OUTPUT ACCEPT [82:6393]
:POSTROUTING ACCEPT [82:6393]
-A POSTROUTING -s 10.0.0.0/24 -o eth0 -j MASQUERADE
COMMIT
# Completed on Mon Aug 15 12:52:13 2011

IPv4 forwarding in sysctl is enabled. The iptables modules are loaded. It doesn't work. I tried MASQUERADE, SNAT and every
possible guide on the net, nothing works. What's the problem here?

EDIT:
I have managed to solve the issue - emberassingly enough it wasn't iptables that failed... my default route within the ad-hoc mesh
was bad.

Last edited by Sadface (2011-08-15 10:59:39)

Offline

Board footer

Powered by FluxBB