l00ny_tn1
asked on
Problems with LINUX as a router - Masquerading, NAT, Internet connection sharing
Hello,
I have the following problem:
I want to use a linux box as a gateway to the internet. It is connected through a DSL (dialup) connection (ppp0 -> eth1).
I want to have access from clients connected to this machine through wireless connections. There is a notebook, running Windows2000. I can ping the linux box and vice versa. Trying to surf to e.g. www.google.com doesn't work.
What I have done so far:
Linux (fedora, kernel 2.6.8) IP on device atml0 (this is the wireless device): 192.168.0.1
Win2k IP: 192.168.0.99
DNS AND gateway on Win2K: 192.168.0.1
/etc/rc.d/rc.ipmasq:
#!/bin/sh
IPTABLES=/sbin/iptables
$IPTABLES -F -t nat
$IPTABLES -A POSTROUTING -t nat -o ppp0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forw ard
Whats wrong? Can anybody help?
loony
I have the following problem:
I want to use a linux box as a gateway to the internet. It is connected through a DSL (dialup) connection (ppp0 -> eth1).
I want to have access from clients connected to this machine through wireless connections. There is a notebook, running Windows2000. I can ping the linux box and vice versa. Trying to surf to e.g. www.google.com doesn't work.
What I have done so far:
Linux (fedora, kernel 2.6.8) IP on device atml0 (this is the wireless device): 192.168.0.1
Win2k IP: 192.168.0.99
DNS AND gateway on Win2K: 192.168.0.1
/etc/rc.d/rc.ipmasq:
#!/bin/sh
IPTABLES=/sbin/iptables
$IPTABLES -F -t nat
$IPTABLES -A POSTROUTING -t nat -o ppp0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forw
Whats wrong? Can anybody help?
loony
Unless you've set up Bind on your Linux box you'll need to configure windows to use the same name server IP(s) that you find in /etc/resolv.conf. Your firewall set up should work as configured and when you fix the nameserver the 2k box should be able to surf.
ASKER
I thought it could have something to do with the DNS entry on the Win2k box, but even if i have set it to the one shown in /etc/resolv.conf it doesn't work. What else could it be? By the way: How do I set up a bind on the linux box?
loony
loony
ASKER
Some extra info:
Output of
/sbin/iptables -L
==============
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:domain
ACCEPT udp -- anywhere anywhere udp dpt:domain
ACCEPT tcp -- anywhere anywhere tcp dpt:netbios-ns
ACCEPT tcp -- anywhere anywhere tcp dpt:netbios-dgm
ACCEPT tcp -- anywhere anywhere tcp dpt:netbios-ssn
ACCEPT tcp -- anywhere anywhere tcp dpt:4662
ACCEPT udp -- anywhere anywhere udp dpt:4223
ACCEPT icmp -- anywhere anywhere icmp echo-request limit: avg 5/min burst 5
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT all -- anywhere localhost.localdomain
LOG all -- anywhere anywhere limit: avg 10/hour burst 5 LOG level warning prefix `IPTABLES: '
Chain FORWARD (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere anywhere state NEW,RELATED,ESTABLISHED
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
/sbin/iptables -t NAT -L
===================
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Hm... Anybody?
Output of
/sbin/iptables -L
==============
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:domain
ACCEPT udp -- anywhere anywhere udp dpt:domain
ACCEPT tcp -- anywhere anywhere tcp dpt:netbios-ns
ACCEPT tcp -- anywhere anywhere tcp dpt:netbios-dgm
ACCEPT tcp -- anywhere anywhere tcp dpt:netbios-ssn
ACCEPT tcp -- anywhere anywhere tcp dpt:4662
ACCEPT udp -- anywhere anywhere udp dpt:4223
ACCEPT icmp -- anywhere anywhere icmp echo-request limit: avg 5/min burst 5
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT all -- anywhere localhost.localdomain
LOG all -- anywhere anywhere limit: avg 10/hour burst 5 LOG level warning prefix `IPTABLES: '
Chain FORWARD (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere anywhere state NEW,RELATED,ESTABLISHED
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
/sbin/iptables -t NAT -L
===================
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Hm... Anybody?
ASKER
Okay, I got it:
For anybody having the same probs:
Reset any firewall rules (for testing though <g>), then do the following:
iptables -F -t nat
iptables -A POSTROUTING -t nat -o ppp0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forw ard
iptables -A FORWARD -t filter -i atml0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -t filter -i ppp0 -m state --state ESTABLISHED,RELATED -j ACCEPT
(where atml0 is the interface connected to the lan (perhaps eth1 for you?!), ppp0 is the interface connected to the internet (perhaps something other like eth0 for you?!))
Don't forget to set the DNS server on the clients to the one given by DHCP of your isp (/etc/resolv.conf)...
For me, it seems it was a problem with the rules I set up to protect the router/gateway.
loony
For anybody having the same probs:
Reset any firewall rules (for testing though <g>), then do the following:
iptables -F -t nat
iptables -A POSTROUTING -t nat -o ppp0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forw
iptables -A FORWARD -t filter -i atml0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -t filter -i ppp0 -m state --state ESTABLISHED,RELATED -j ACCEPT
(where atml0 is the interface connected to the lan (perhaps eth1 for you?!), ppp0 is the interface connected to the internet (perhaps something other like eth0 for you?!))
Don't forget to set the DNS server on the clients to the one given by DHCP of your isp (/etc/resolv.conf)...
For me, it seems it was a problem with the rules I set up to protect the router/gateway.
loony
Hi,
Good that you found a solution but I can give u a small hint. When you want to chase IPTABLES buys, then use the utility "tcpdump". By seeing the packets arrriving and going, you can diagnose the problems easily.
Actually you could have jsut set the DNS server addresses in the clients to the one supplied by ur ISP and seen if it worked...?
Just my 2 cents,
Cheers,
karan
Good that you found a solution but I can give u a small hint. When you want to chase IPTABLES buys, then use the utility "tcpdump". By seeing the packets arrriving and going, you can diagnose the problems easily.
Actually you could have jsut set the DNS server addresses in the clients to the one supplied by ur ISP and seen if it worked...?
Just my 2 cents,
Cheers,
karan
ASKER
Thanks, a really cool tool this tcpdump is :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.