Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm having problem setting connection sharing in my Slackware system. I enabled rc.ip_forward:

$ cat /proc/sys/net/ipv4/ip_forward 
1

And I added the next iptables rule (and I've no other rules):

iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE

This is the output of ifconfig:

$ /sbin/ifconfig
eth0      Link encap:Ethernet  HWaddr 6c:62:6d:91:7f:3f  
          inet addr:10.42.0.1  Bcast:10.42.0.255  Mask:255.255.255.0
          inet6 addr: fe80::6e62:6dff:fe91:7f3f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:528 errors:0 dropped:36 overruns:0 frame:0
          TX packets:92 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:292440 (285.5 KiB)  TX bytes:32536 (31.7 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:349 errors:0 dropped:0 overruns:0 frame:0
          TX packets:349 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:27128 (26.4 KiB)  TX bytes:27128 (26.4 KiB)

wlan0     Link encap:Ethernet  HWaddr 14:d6:4d:48:b0:cd  
          inet addr:131.114.43.177  Bcast:131.114.43.255  Mask:255.255.252.0
          inet6 addr: fe80::16d6:4dff:fe48:b0cd/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:19695 errors:0 dropped:0 overruns:0 frame:0
          TX packets:18023 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:9712346 (9.2 MiB)  TX bytes:3213810 (3.0 MiB)

Where wlan0 is the interface connected to the internet. eth0 ip address is set manually with netconfig, while wlan0 is assigned with dhcp by the access point.

Connected to eth0 there's a router with its own dhcp server, so I don't need to run one on my system. The router is on 192.168.1.1 and is serving address from 192.168.1.100. There's no hardware problem since I'm able to do it with Ubuntu and NetworkManager (with "shared with other" checkbox for eth0).

How can I troubleshot this?

share|improve this question
    
Check iptables rules by iptables -L as root. Look for Chain FORWARD, if there is policy DROP and no other rules, then you should add iptables rules to allow forwarding. NOT safe, but for testing sufficient way is to set iptables -P FORWARD ACCEPT –  week Nov 12 '12 at 11:50
    
@week, Hi. Unfortunately all other chains are already on ACCEPT as default action and I've no other rules that may interfere. –  Zagorax Nov 12 '12 at 11:55
    
Try to set default rule to DROP and add iptables -A FROWARD -i eth0 -o wlan0 -j ACCEPT and iptables -A FROWARD -i wlan0 -o eth0 -j ACCEPT. –  week Nov 12 '12 at 11:59
    
Another thing, That router with dhcp is set to do nat also? Or why are you using 10.42.0/24 adress for eth0, if network is in 192.168.1/24? –  week Nov 12 '12 at 12:04
    
If you have eth0 connected to WAN port of router, then check if router's wan interface is set properly to 10.42.0/24 site and has default gw to 10.42.0.1. –  week Nov 12 '12 at 12:06

1 Answer 1

This should work:

iptables -t nat -A POSTROUTING -o wlan0 -s 10.42.0.0/24 -j MASQUERADE
iptables -A FORWARD -i wlan0 -o eth0 -m state \
            --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.