View previous topic :: View next topic |
Author |
Message |
bonito Tux's lil' helper
![Tux's lil' helper Tux's lil' helper](/images/ranks/rank_rect_1.gif)
Joined: 01 May 2002 Posts: 80
|
Posted: Mon Jun 17, 2002 7:09 pm Post subject: iptables not routing correctly |
|
|
Hello, if anyone can help me with this problem I would appreciate it. I am trying to have users on an external network (the internet) access a server daemon running on an internal machine. I have had this working previously but now it seems not to work. Here is what I currently do, can anyone tell me if there is anything else I should do to make it work?
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING -p tcp --dport 123 -i eth0 -j DNAT --to 192.168.10.1:123
iptables -t nat -A PREROUTING -p tcp --dport 124 -i eth0 -j DNAT --to 192.168.10.1:124
iptables -t nat -A PREROUTING -p udp --dport 123 -i eth0 -j DNAT --to 192.168.10.1:123
iptables -t nat -A PREROUTING -p udp --dport 124 -i eth0 -j DNAT --to 192.168.10.1:124
ps I do have all the netfilter options compiled into the kernel and it is a gentoo machine. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Damasz Tux's lil' helper
![Tux's lil' helper Tux's lil' helper](/images/ranks/rank_rect_1.gif)
![](images/avatars/gallery/The Fifth Element/movie_the_fifth_element_leeloo.gif)
Joined: 24 Apr 2002 Posts: 91 Location: Groningen, the Netherlands
|
Posted: Tue Jun 18, 2002 9:27 am Post subject: |
|
|
I had to enable the way back as well, so my setup is:
/sbin/iptables -t nat -A PREROUTING -i eth0 -d 1.2.3.4 -j DNAT --to-destination 5.6.7.8
/sbin/iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to-source 1.2.3.4
The last line should do the trick for you. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
bonito Tux's lil' helper
![Tux's lil' helper Tux's lil' helper](/images/ranks/rank_rect_1.gif)
Joined: 01 May 2002 Posts: 80
|
Posted: Tue Jun 18, 2002 6:16 pm Post subject: |
|
|
Thanks for the tip, but actually I found out now that it isnt a case of what I have been typing not working correctly as I have managed to get it working on a mandrake box with the same commands I had used before. I am now compiling a new kernel with every possible tcp/ip networking option enabled and with all netfilter options enabled and options recommended to be enabled as stated on the netfilter website. I hope this works, it is critical for me to have this working when it comes to convincing my boss to implement gentoo at the office...and after using mandrake the past year, I WANT Gentoo.
Update: I just recompiled the kernel and tested it, and the routing I am attempting is still not working. I am at a loss for what to do. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Scrapz n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 06 Jun 2002 Posts: 21
|
Posted: Thu Jun 20, 2002 1:21 pm Post subject: |
|
|
When you testing it, are you getting someone on the external network (the internet) to test it for you? Because if you test on the internal network, it wont work. The rules are set to listen to the external network for requests and only forwards from the external network. So chances are it working already, you just cant test on the internal network. I suppose you could make rules to forward on the internal network, by duplicating your current rules subsituing eth0 for eth1 - I havnt tried this, my guess is make it messy and even get into loops.
TTFN,
Scrapz ![Wink :wink:](images/smiles/icon_wink.gif) |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
klieber Bodhisattva
![Bodhisattva Bodhisattva](/images/ranks/rank-bodhisattva.gif)
![](images/avatars/71602131143de10f19aaec.jpg)
Joined: 17 Apr 2002 Posts: 3657 Location: San Francisco, CA
|
Posted: Thu Jun 20, 2002 1:38 pm Post subject: |
|
|
A very, very good iptables tutorial can be found here
--kurt _________________ The problem with political jokes is that they get elected |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
hamletmun Tux's lil' helper
![Tux's lil' helper Tux's lil' helper](/images/ranks/rank_rect_1.gif)
![](images/avatars/204432215642e16a03cf17a.jpg)
Joined: 13 Jun 2002 Posts: 111 Location: Buenos Aires, Argentina
|
Posted: Sat Jul 06, 2002 7:37 pm Post subject: HOWTO - Make your Internet Connection Sharing to work |
|
|
HOWTO - Make your Internet Connection Sharing to work
From ISP to GENTOO - (eth0:DHCP or STATIC IP)
From GENTOO to WINDOWS - (eth1:192.168.0.1)
1.
insmod your.nic.module (i.e. "insmod 3c59x") for both nics if differ
2.
if your ISP uses DHCP, "dhcpcd eth0"
if static, "ifconfig eth0 your.static.ip netmask 255.255.255.0 gateway your.isp.gateway"
Now is time to configure the connection sharing
this is just for kenels greater than 2.4.x with iptables
1.
insmod iptables_nat
2.
echo 1 >/proc/sys/net/ipv4/ip_forward
3.
iptables -F
iptables -t nat -F
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
(if your linux uses eth0 to connect your isp)
4.
In the Windows Machine:
192.168.0.1 in the gateway
numbers from your /etc/resolv.conf in DNS server |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|