Configure network

We have a DNS server acting as gateway for all devices connected through the wlan0 interface. All packets it receives from the wlan0 interface will get redirected to the eth0 interface.

Configure DNS

We will add entries in our DNS zone to be able to reach the development host from our smartphone.

Network topology:

  • LAN: 192.168.1.0
  • WiFi: 192.168.2.0
+-----------------------------+
|  DNS     192.168.1.101  eth0|----- Development host 192.168.1.16
|                             |
| server   192.168.2.101 wlan0|----- Smartphone
+-----------------------------+
/etc/bind/db.tl.tl:
-------------------
; tl.tl zone
$TTL	604800
@	IN	SOA	hal.tl.tl. 	info.tl.tl. (
...
; DNS servers
@   IN  NS  hal.tl.tl.
; Local servers
hal                 IN  A       192.168.1.101
...
; phonegap
pg                  IN  A       192.168.1.16    <=== Development host
_$: service bind9 restart
 * Stopping domain name service... bind9                [ OK ]
 * Starting domain name service... bind9                [ OK ]

wlan0

/etc/network/interfaces:
------------------------
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
	...

# The wireless interface.
auto wlan0
iface wlan0 inet static
	address 192.168.2.101
	network 192.168.2.0
	netmask 255.255.255.0
	dns-nameservers 127.0.0.1

iptables

/etc/iptables.up.rules:
-----------------------
*nat
:PREROUTING ACCEPT  [0:0]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT      [0:0]
-A POSTROUTING -s 192.168.2.0/24 -o eth0 -j MASQUERADE
COMMIT
*filter
:INPUT ACCEPT   [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT  [0:0]
COMMIT
_$: iptables-restore < /etc/iptables.up.rules