I have an Host A where I have my VM running Kali and Host B, which is a Win computer.
I want to have Host A as the only one computer connected to the Internet, so Host B must pass through Host A via an Ethernet cable in order to connect.
Host A needs to also act as a DNS & DHCP server for Host B, so I’m trying to configure
Host A is connected over the
wlan0 interface on the
I have configured a static IP for the
eth0 interface which will be responsible for acting as a DHCP server on the
Then I edited the
/etc/network/interfaces file as follows:
iface lo inet loopback
iface eth0 inet static
iface wlan0 inet dhcp
Here is my
/etc/dnsmasq.conf configuration file:
Basically I want the DHCP server to lease IP addresses for the
192.168.2.0 network, the one that will connect via the Ethernet cable the two computers.
And here is my
At this point I created (and made it executable) the following file
/etc/network/if-pre-up.d/router_firewall which is responsible to route the traffic from the
192.168.2.0 network to the
192.168.1.0 network (the one with the internet access):
# script for source Network Address Translation using iptables
iptables -t nat -F
iptables -N val_input
iptables -N val_output
# allow packets with NEW, ESTABLISHED and RELATED states
iptables -A val_input -m state --state NEW,ESTABLISHED,RELATED -i lo -j RETURN
iptables -A val_output -m state --state NEW,ESTABLISHED,RELATED -o lo -j RETURN
iptables -A val_input -m state --state NEW,ESTABLISHED,RELATED -i eth0 -j RETURN
iptables -A val_output -m state --state NEW,ESTABLISHED,RELATED -o eth0 -j RETURN
iptables -A val_input -m state --state NEW,ESTABLISHED,RELATED -i wlan0 -j RETURN
iptables -A val_output -m state --state NEW,ESTABLISHED,RELATED -o wlan0 -j RETURN
iptables -A val_input -j DROP
iptables -A val_output -j DROP
iptables -A INPUT -p tcp -j val_input
iptables -A OUTPUT -p tcp -j val_output
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
At this point I have checked the configurations file for days and I cannot understand why it is not working. When I connect the two computers via cable (cross over one), the win computer is not getting the IP from the
eth0 interface of the Kali machine.
- The Win machine is configured to get automatically an IP from DHCP.
dnsmasq service is enabled and running.
- IP forwarding is enabled
Really hope someone can help here!