9 comments on “Sharing a wireless connection via ethernet port

  1. Hi I’m very thankful, that you posted this instruction.
    Thats what I was looking for the last time very intensive.

    My only fear is, that the iptaple configurations stay persistent after doing this. Until now I never had to do with iptable configuration and therefore have not the least inkling on how to reset them back to defaults.

    You wrote, there only active until reboot, but wrote too, that you didn’t test it.

    If you a have a way on how to completely reset the iptables config, I would be thankful.

    Best regards

  2. Great post! Ran perfectly.

    The only problem I had was that the gateway option was not available in my client’s ifconfig command. Solution is not to put it and then set it with the route command:

    # routeadd default gw


  3. It worked like a charm, i’m using Debian as server and Windows as the client PC.

    I have two doubts…

    ¿Why the nameserver is (i put this in the DNS configuration on Windows)

    I want to automate this everytime i startup the server without using DHCP (i like to have static IP address)..so i guess i have to configure first /etc/network/interfaces to configure eth0 and then execute the iptables command ¿how can i do that, is there any /etc/* script that i can use for this?

    • I am sure any nameserver would do. You should be able to save current iptables config with iptables-save > /etc/network/iptables-wireless.cfg and symlink into the pre-up sub-directory.

  4. #!/bin/bash
    # Should be called wireless2wire.sh
    # Internet between friends!
    # Script to share Internet from wireless connection to wired.
    # Designed for a fairly standard Debian/Ubuntu desktop system.
    # Requires dnsmasq:
    # sudo apt-get install dnsmasq
    # Requires ccze:
    # sudo apt-get install ccze
    # Make owner root:
    # sudo chown root:root wireless2wire.sh
    # Make executable:
    # sudo chmod u+x wireless2wire.sh
    # Copy to executable path:
    # sudo cp wireless2wire.sh /usr/local/bin
    # Run as root:
    # sudo wireless2wire.sh
    # Edit next line if your router is on the same subnet,
    # e.g. 192.168.10.X
    ifconfig eth0 “$SUBNET”.1 netmask
    sysctl -w net.ipv4.ip_forward=1
    echo “interface=eth0” > /etc/dnsmasq.conf
    echo “dhcp-range=”$SUBNET”.10,”$SUBNET”.100,4h” >> /etc/dnsmasq.conf
    iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
    iptables -F FORWARD
    iptables -A FORWARD -j ACCEPT
    service dnsmasq restart
    iptables -nvL
    cat /etc/dnsmasq.conf | ccze -A
    route -n
    tail -f /var/log/syslog | ccze -A

    # Now your friend should be able to check, see the syslog,get an IP
    # through a cable between your computer and hers, and use your
    # wireless connection.
    # Dharma
    # Fuente: http://chrisjrob.com/2011/03/14/sharing-a-wireless-connection-via-ethernet-port/

  5. Pingback: How do I route internet in from wlan0 and out through eth0 in debian/centOS?

  6. Pingback: Unable to share internet connection with correct settings | DL-UAT

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s