Pages

Affichage des articles dont le libellé est [ubuntu] Internet shareing with IP Tables and external 2 nics - depending on connection. Afficher tous les articles
Affichage des articles dont le libellé est [ubuntu] Internet shareing with IP Tables and external 2 nics - depending on connection. Afficher tous les articles

[ubuntu] Internet shareing with IP Tables and external 2 nics - depending on connection

vendredi 22 juillet 2016

Hi there, I hope someone will be able to help me. I have a small pc I run in the car that acts as a media server for the kids tablets. Its running ubuntu 16.04 server edition and plex media server. It has an onboard wifi card that is set up using hostapd and dnsmasq to act as a hotspot for the kids tablets to connect to. In addition there is an onboard ethernet card which connects via dhcp. I have used IP tables to share the internet connection to the wifi hotspot. This is great when there is a wired network connection but obviously that doens't happen in the car. I was thinking of either adding an additional wifi dongle connecting to my phones 4G or buying a 4G usb modem. My question is, can I have a rule in the IP tables to forward internet traffic from the Ethernet card when connected or the additional wifi dongle instead?

My /etc/network/interfaces file

Code:

auto lo wlp3s0 enp2s0f5
iface lo inet loopback

iface enp2s0f5 inet dhcp

auto wlp3s0
iface wlp3s0 inet static
        address 192.168.12.1
        netmask 255.255.255.0
        network 192.168.12.0
My dnsmasq.conf

Code:

listen-address=127.0.0.1
listen-address=192.168.12.1
bind-dynamic
dhcp-range=192.168.12.1,192.168.12.254,255.255.255.0,24h
dhcp-option-force=option:router,192.168.12.1
dhcp-option-force=option:dns-server,192.168.12.1
dhcp-option-force=option:mtu,1500
no-hosts
My hostapd.conf

Code:

beacon_int=100
ssid=CarAP
interface=wlp3s0
driver=nl80211
channel=1
ignore_broadcast_ssid=0
ap_isolate=0
hw_mode=g
wpa=2
wpa_passphrase=xxxxxxxxx
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
rsn_pairwise=CCMP
My rc.local file

Code:

/sbin/iptables -P FORWARD ACCEPT
/sbin/iptables --table nat -A POSTROUTING -o enp2s0f5 -j MASQUERADE
I added this to the sysctl.conf

Code:

et.ipv4.ip_forward=1
Thanks

Let's block ads! (Why?)



[ubuntu] Internet shareing with IP Tables and external 2 nics - depending on connection
Read more ...