It's been more than 1 week am trying to configure my Pi as an internet gateway. I've played with several 10s of configurations shown on the web, but none of them work.
here's my setup: hard: a Pi with an external USB <---> ethernet device soft: Raspbian scratch with hostapd and dnsmasq running
I've disabled DHCP and wifi of my adsl modem.
here's what i want to achieve: eth0: the pi's onboard ethernet. it will be connected to a hub and serve as a DHCP server to my local wired network.
eth1: only the USB<--->eth is connected to my modem. i want it to be the only link of my whole ( wired and wireless ) local network with the outside world thru my adsl modem.
wlan0: will be the wifi access-point of my local network.
all 3 devices own their IP configured as static in the /etc/networks/interfaces file. here's the file:
auto eth1 iface eth1 inet static address 192.168.1.1 netmask 255.255.255.0 gateway 192.168.1.254 dns-nameservers 192.168.1.254 metric 200 auto eth0 iface eth0 inet static address 192.168.0.254 netmask 255.255.255.0 metric 202 auto lo iface lo inet loopback auto wlan0 iface wlan0 inet static address 192.168.0.253 netmask 255.255.255.0 metric 201 EOF ------------------------
the dnsmasq DHCP server gives IPs to local wired and wireless devices. it is setup like this in /etc/dnsmasq.conf:
interface=eth0 # Use interface eth0 listen-address=192.168.0.254 # Explicitly specify the address to listen on bind-interfaces # Bind to the interface to make sure we aren't sending things elsewhere server=192.168.0.254 # Forward DNS requests to Google DNS domain-needed # Don't forward short names bogus-priv # Never forward addresses in the non-routed address spaces. dhcp-range=eth0,192.168.0.1,192.168.0.100,255.255.255.0,12h interface=wlan0 # Use interface wlan0 listen-address=192.168.0.253 # Explicitly specify the address to listen on bind-interfaces # Bind to the interface to make sure we aren't sending things elsewhere server=192.168.0.254 # Forward DNS requests to Google DNS domain-needed # Don't forward short names bogus-priv # Never forward addresses in the non-routed address spaces. dhcp-range=eth0,192.168.0.101,192.168.0.200,255.255.255.0,12h
tho you can se all of them, here's my static IPs:
*my modem: static ip 192.168.1.254
*eth0: static ip 192.168.0.254
*eth1: static ip 192.168.1.1 ( as it's connected to my modem )
*wlan0: static ip 192.168.0.253
I also configured routing thru iptables with those commands:
# Allow traffic initiated from LAN to access "the world" iptables -I FORWARD -i eth0 -o eth1 -s 192.168.0.0/24 -m conntrack --ctstate NEW -j ACCEPT iptables -I FORWARD -i wlan0 -o eth1 -s 192.168.0.0/24 -m conntrack --ctstate NEW -j ACCEPT # Allow established traffic to pass back and forth iptables -I FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT # Masquerade traffic from LAN to "the world" iptables -t nat -I POSTROUTING -o eth1 -s 192.168.0.0/24 -j MASQUERADE
what i get is really weird ! eth0<---->eth1 routing works like a charm ! OR wlan0<--->eth1 routing works like a charm as well !
but i've been totally unable to make both work at the same time.
anybody got an idea ? I'd like to redo a whole setup as i guess i messed around many things and am now sure of nothing ( interfaces setup, dnsmasq config, hostapd config, etc.... )
as a crappy solution i think i gonna setup 2 PIs: one as eth0<--->eth1 gateway and a second one, connected to my local network hub, used as a wifi access-point. I really hate this solution but i got no other one and i confess that after hours of try and redo am somewhat bored and fed-up :-(
I also posted questions on other forums with no answer.