Sign in to follow this  
Followers 0

Howto: Ubuntu dapper + internet connection sharing

1 post in this topic

This thread is slightly different to the last as it describes how to enable internet connection sharing over an ad-hoc network, as opposed to just connecting to an Ad-Hoc network with a static IP, I decided to put it into a seperate thread as it relates to configuring a seperate card and I didn't want the other thread getting too busy

My network is set up as so:

ADSL Router -> ethernet -> Dapper PC -> wireless -> Dapper Laptop

Here are the instructions on how to set up the Dapper PC to share the internet to lan clients:

Under the x86_64 Dapper beta 2, the network configuration program crashes, so I installed the i386 version of Dapper beta 2 and now it works.

My ethernet card, connected to the router, was already configured by DHCP, so all I had to do was set up the PCs ra0 card with a static IP address

This wasn't as simple as I thought, we can set it up with ubuntus network configuration manager and it will save the settings correctly to /etc/network/interfaces but it will not set it up as an Ad-Hoc network, to do this you must issue iwconfig ra0 mode Ad-Hoc

iwconfig ra0 essid Z3r0 #your essid here

My PC could now ping the laptop, the laptop could now ping the PC, but the laptop couldn't reach the internet through the PC, this requires another step

modprobe iptable_nat

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

echo 1 > /proc/sys/net/ipv4/ip_forward

The laptop can now access the internet

Finally add these commands to rc.local to execute on each bootup

iwconfig ra0 mode Ad-Hoc

iwconfig ra0 essid Z3r0 #your essid here

modprobe iptable_nat

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

echo 1 > /proc/sys/net/ipv4/ip_forward


if you have wireless-mode Ad-Hoc in /etc/network/interfaces your PC will freeze the PC after logging in, do not put it in there, issuing post-up wireless-mode Ad-Hoc doesn't work and pre-up will cause the system not to boot

It is therefore necessary to add the command to rc.local as above.

I had a look at WEP, issuing iwconfig ra0 key s:1234567891011 works but the laptop and PC fail to communicate, I already know it works as the laptop was working with windows before with WEP, so I assume that the drivers are broken? or there is another unknown to me configuration option


Just for clarity

/etc/network/interfaces should look like this:

auto lo

iface lo inet loopback

#The primary network interface configured via DHCP

auto eth0

iface eth0 inet dhcp

auto ra0

iface ra0 inet static



gateway #my router

/etc/resolv.conf should look like this:

nameserver #my router or your ISPs DNS server instead


Edited by Z3r0

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.