Linux – Share an internet connection with Debian

debianlinuxlinux-networkingnetworkingwifi

Here's my current /etc/network/interfaces file on the "server":

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp
    name Wired Network

auto ath0
iface ath0 inet static
    name Wireless Network
    address 10.1.1.1
    netmask 255.255.255.0
    broadcast 10.1.1.255
    wireless-channel 1
    wireless-essid MYNETWORKNAME
    madwifi-base wifi0
    madwifi-mode Master

eth0 (wired connection) works fine on the server, I can ping google.com for example. /etc/resolv.conf has the correct nameservers.

ath0 (wireless connection) also works fine, clients can connect to the server via ssh, for example: root@10.1.1.1

Currently clients are configured:

  • Connect to ESSID: MYNETWORKNAME

  • Static IP: 10.1.1.[2-254]

  • Subnet: 255.255.255.0

What I want now is for clients to connect to MYNETWORKNAME and have internet access.

I load the interfaces file with:
/etc/init.d/networking [restart|start|stop]
(no network-manager, wicd etc.)

Thanks! (:

Best Answer

You can run a NAT/Firewall software like Firestarter on the server.

Another solution without running anything is to do the NAT manually with iptables on NAT Table postrouting using Masquerade on your output external interface (eth0). See rule below:

-A POSTROUTING -o eth0 -j MASQUERADE 

and you will need to enable ip forwarding with:

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