Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

After setting up network sharing the easy way on the Ubuntu machine, and getting an IP address via DHCP on the Arch Linux machine downstream, the Arch machine is able to ssh to the Ubuntu machine and resolve DNS, but not communicate with the Internet (ping, pacman time out). From the Arch Linux machine:

$ ip route show dev net0
default via 10.42.0.1 metric 202
10.42.0.0/24 proto kernel scope link src 10.42.0.15 metric 202
$ ip addr show dev net0
...
inet 10.42.0.15/24 brd 10.42.0.255 scope global net0
...

On the Ubuntu machine:

$ ip addr show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether e8:11:32:66:e3:4d brd ff:ff:ff:ff:ff:ff
    inet 10.42.0.1/24 brd 10.42.0.255 scope global eth0
    inet6 fe80::ea11:32ff:fe66:e34d/64 scope link 
       valid_lft forever preferred_lft forever
$ ip addr show dev wlan0
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 88:53:2e:1b:4b:1c brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.64/24 brd 192.168.1.255 scope global wlan0
    inet6 fe80::8a53:2eff:fe1b:4b1c/64 scope link 
       valid_lft forever preferred_lft forever

Could it be that the automatic NAT setup on Ubuntu failed? I'm not sure how that works, so how would I detect that?

share|improve this question
    
Can I answer Internet share using iptables ? –  Rahul Patil Sep 7 '13 at 7:20
    
@RahulPatil If it explains how in a concise manner, sure. The goal is to solve routing in the simplest manner possible. –  l0b0 Sep 7 '13 at 8:51
    
you mean "10.42.0.1" should act as gateway/router for other computer in network ? –  Rahul Patil Sep 7 '13 at 19:06
    
once check with enable ip forwarding then let me know. ducea.com/2006/08/01/how-to-enable-ip-forwarding-in-linux –  Rahul Patil Sep 7 '13 at 20:02
    
IP forwarding was enabled. –  l0b0 Sep 22 '13 at 7:45

1 Answer 1

Only one thing puzzles me, here: you say that DNS from the Arch machine is working. If your DNS server is your Ubuntu box, great. If your DNS server is external, then I'm confused. I'm not intimately familiar with Arch -- only installed it once -- but you can usually check /etc/resolv.conf to see who your DNS servers are. If they are internal, most likely your NAT or forwarding on the Ubuntu box aren't working. If they are external -- which means you are successfully resolving DNS queries against an external host -- your problem is likely an iptables issue.

From a "what's likely to go wrong" perspective, it's far more likely to be forwarding/NAT. So: * Verify forwarding is, indeed, enabled on the Ubuntu box: fireapple# cat /proc/sys/net/ipv4/conf/all/forwarding 1 If it returns "0", likely your forwarding isn't enabled. To temporarily fix it, simply fireapple# echo 1 > /proc/sys/net/ipv4/conf/all/forwarding To make it last through a reboot, edit /etc/sysctl.conf and add (or modify to look like) the following line: net.ipv4.ip_forward = 1

Next, a quickie how-to-set-up-NAT script. Plug the following into, say, "NAT.sh", make sure you've "chmod +x"'d it, and put it in /usr/local/bin/. Note that I've made assumptions about which interface is doing what, based on the fact that both hosts have 10.42.0.0/24 addresses: export INTERNET=wlan0 # Assuming eth0 is your Internet-facing address export INTERNAL=eth0 # Likewise, assuming your WiFi is internal iptables --flush # Clean slate iptables -t nat -A POSTROUTING -o $INTERNAL -j MASQUERADE iptables -A FORWARD -i $INTERNAL -o $INTERNET -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -A FORWARD -i $INTERNET -o $INTERNAL -j ACCEPT

Once that's in-place, execute it (e.g., "sudo /usr/local/bin/NAT.sh"); if all goes well, you should be able to talk freely to the outside world.

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.