LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   NAT eth0 through wlan0? (http://www.linuxquestions.org/questions/linux-networking-3/nat-eth0-through-wlan0-747891/)

sysslack 08-16-2009 04:58 AM

NAT eth0 through wlan0?
 
Hi
computer1 running CentOS5

nic eth0 connected to computer 2
nic wlan0 connection to internet

computer2 running Debian lenny

nic eth0 connected to computer1 through cross cable

Is it possible to surf the internet from computer2 with this setup ?
I have tried with this rules on computer1, but it did not work
root@localhost ~]# iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
[root@localhost ~]# echo 1 > /proc/sys/net/ipv4/ip_forward

Computer1
root@localhost ~]# netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.2.0 * 255.255.255.0 U 0 0 0 wlan0
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
default 192.168.2.254 0.0.0.0 UG 0 0 0 wlan0

[root@localhost ~]# ifconfig
eth0 inet addr:192.168.0.5 Bcast:192.168.0.255 Mask:255.255.255.0
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
wlan0 inet addr:192.168.2.12 Bcast:192.168.2.255 Mask:255.255.255.0


Computer2
# netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
default 192.168.0.1 0.0.0.0 UG 0 0 0 eth0

root# ifconfig

eth0 inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0

jschiwal 08-16-2009 07:54 AM

Could you provide information on your wireless connection? If you are using a wireless NAT router, you can have the wired connection on a subnet and use forwarding. If your router is a nat router, you don't need to configure masquerading on the first computer (with wireless). The router can do it.

I did this once to share wireless connection on my laptop, for my desktop. You need to enable ip forwarding. I found that I also needed to load the conntrack module to get it to work. (was called ip_conntrack but now is called nf_conntrack)
You may be able to enable ip forwarding in your distro's device configuration, or in a boot up script that includes the line:
echo 1 >/proc/sys/net/ipv4/ip_forward

sysslack 08-17-2009 06:37 AM

Thank you for your answer!I guess I am missing module nf_conntrack


All times are GMT -5. The time now is 04:26 AM.