Networking Forums

Networking Forums > Computer Networking > Linux Networking > Forwarding UDP Packets using SNAT

Reply
Thread Tools Display Modes

Forwarding UDP Packets using SNAT

 
 
poduval@gmail.com
Guest
Posts: n/a

 
      03-09-2006, 09:13 AM
I am trying to do the following

192.168.1.1
A --------------- B
192.168.1.2 | 10.1.1.127
|
C (10.1.1.1)

UDP packets from 10.1.1.1 need to be forwarded to 192.168.1.2. The
destination address on the UDP packets is 192.168.1.2. I can see that
packets are being received succesffuly on eth1 of Device B. However,
it is not forwarded to Device A.

My iptables rules are as follows :

echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -P INPUT ACCEPT
iptables -F INPUT
iptables -P OUTPUT ACCEPT
iptables -F OUTPUT
iptables -P FORWARD DROP
iptables -F FORWARD
iptables -t nat -F

iptables -A FORWARD -i eth0 -o eth1 -m state -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
iptables -A FORWARD -j LOG
iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to 192.168.1.1

Can anyone show me where the mistake lies ?

 
Reply With Quote
 
 
 
 
Eric Teuber
Guest
Posts: n/a

 
      03-09-2006, 07:31 PM
(E-Mail Removed) wrote:
> I am trying to do the following
>
> 192.168.1.1
> A --------------- B
> 192.168.1.2 | 10.1.1.127
> |
> C (10.1.1.1)
>
> UDP packets from 10.1.1.1 need to be forwarded to 192.168.1.2. The
> destination address on the UDP packets is 192.168.1.2. I can see that
> packets are being received succesffuly on eth1 of Device B. However,
> it is not forwarded to Device A.
>
> My iptables rules are as follows :
>
> echo "1" > /proc/sys/net/ipv4/ip_forward
> iptables -P INPUT ACCEPT
> iptables -F INPUT
> iptables -P OUTPUT ACCEPT
> iptables -F OUTPUT
> iptables -P FORWARD DROP
> iptables -F FORWARD
> iptables -t nat -F
>
> iptables -A FORWARD -i eth0 -o eth1 -m state -j ACCEPT


this rule seems to be wrong, should be like
iptables -A FORWARD -i eth0 -o eth1 -m state ESTABLISHED -j ACCEPT

> iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
> iptables -A FORWARD -j LOG
> iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to 192.168.1.1
>
> Can anyone show me where the mistake lies ?
>


Is your routing set up correctly?

You should see something like
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
after executing /sbin/route

Do you have loaded the ip_conntrack module into the kernel (/sbin/lsmod
| grep conntrack)?

Eric
 
Reply With Quote
 
Eric Teuber
Guest
Posts: n/a

 
      03-09-2006, 07:33 PM
(E-Mail Removed) wrote:
> I am trying to do the following
>
> 192.168.1.1
> A --------------- B
> 192.168.1.2 | 10.1.1.127
> |
> C (10.1.1.1)
>
> UDP packets from 10.1.1.1 need to be forwarded to 192.168.1.2. The
> destination address on the UDP packets is 192.168.1.2. I can see that
> packets are being received succesffuly on eth1 of Device B. However,
> it is not forwarded to Device A.
>
> My iptables rules are as follows :
>
> echo "1" > /proc/sys/net/ipv4/ip_forward
> iptables -P INPUT ACCEPT
> iptables -F INPUT
> iptables -P OUTPUT ACCEPT
> iptables -F OUTPUT
> iptables -P FORWARD DROP
> iptables -F FORWARD
> iptables -t nat -F
>
> iptables -A FORWARD -i eth0 -o eth1 -m state -j ACCEPT


this rule seems to be wrong, should be like
iptables -A FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED -j ACCEPT

> iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
> iptables -A FORWARD -j LOG
> iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to 192.168.1.1
>
> Can anyone show me where the mistake lies ?
>


Is your routing set up correctly?

You should see something like
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
after executing /sbin/route

Do you have loaded the ip_conntrack module into the kernel (/sbin/lsmod
| grep conntrack)?

Eric
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Packets forwarding TroLoo Linux Networking 0 04-10-2007 07:17 PM
Advice on cgi forwarding of packets JohnRHarlow@gmail.com Linux Networking 0 07-22-2005 12:36 PM
iptables SNAT and DNAT on same packets chris-usenet@roaima.co.uk Linux Networking 6 07-08-2005 09:19 AM
Why isn't my Linux box forwarding multicast packets? Wei Linux Networking 1 05-25-2005 08:15 PM
forwarding outgoing packets Nicola Gatti Linux Networking 4 02-17-2004 06:56 AM



1 2 3 4 5 6 7 8 9 10 11