Creating a Debian Router from a virtual machine
I am trying to create a router from a Debian machine on virtual box, but I can't get it to work properly. The router has got two network adapters, one that's bridged, and the other is running an internal network.
After setting up the router, I'm unable to retrieve an IP-address from the internal/private interface (eth1), and I can't understand why.
After booting up the machine I configured the networks interfaces as such:
nano -w /etc/network/interfaces
# The external WAN interface (eth0)
allow-hotplug eth0
iface eth0 inet dhcp
# The internal LAN interface (eth1)
allow-hotplug eth 1
iface eth1 inet static
address 192.168.42.1
netmask 255.255.255.0
network 192.168.42.0
broadcast 192.168.42.255
pre-up iptables-restore < /etc/iptables.rules
Then I installed dnsmasq and configured it like this:
nano -w /etc/dnsmasq.conf
interface=eth1
listen-address=127.0.0.1
dhcp-range=192.168.42.100,192.168.42.110,12h
And finally i configured iptables:
nano -w /etc/iptables.rules
*nat
-A PREROUTING -i eth0 -p tcp -m tcp --dport 50000 -j DNAT --to-destination
192.168.0.3:50000
-A POSTROUTING -o eth0 -j MASQUERADE
COMMIT
*filter
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 222 -j ACCEPT
-A INPUT -i eth0 -j DROP
-A FORWARD -i eth0 -p tcp -m tcp --dport 50000 -m state --state NEW -j
ACCEPT
COMMIT
After this I activated the iptables rules and rebooted, only to get no IP-adress from eth1.
|