Tuesday, October 24, 2017

Unix IPTABLE ipforward


In my home lab, I have KVM installed on HP server and i was managing all the virtul machine through my Ubuntu installed laptop using virt-manager client.

but i couldn't access virtual machines in my wifi enabled networks and there is no virt-manager client for windows operating system.

So i tried to work on setup to configure my KVM machine as router to access all the VM within wifi network lan.

here is the my home lab and wifi  networks

KVM machine  has 

one Ethernet card enp4s0f1 connected to 192.168.1.6( wifi network)
another one is kvm bridge network card connected to 192.168.100.1(vm private network)

Windows Laptop:

My Windows Laptop connected to 192.168.1.4 network)

Using putty on Windows laptop, i was able to connect KVM machine directly and not the virtual machines.

And also if i run any applications(webservers/cloudera manager) i was not able access in my windows laptop.

On Windows Laptop

Update the routing table to send all 192.168.100.0/24 (vm private network) traffic to gatway 192.168.1.6(KVM  wifi network ipaddress)

route add 192.168.100.0 mask 255.255.255.0 192.168.1.6

sudo route add -net 192.168.100.0/24 gw  192.168.1.6 ( On Linux Dekstop)

On KVM Machine

Enable the IPFORWARD

update /etc/sysctl.conf file
net.ipv4.ip_forward=1

run this command to reflect the change.
sysctl -p

IF IPTABLE is enabled, update below rule.

-A FORWARD  -i enp4s0f1 -o virbr1 -j ACCEPT

-I FORWARD 1 -j LOG --log-prefix "RULE4:" --log-level 7 ( to enable debug)
-I FORWARD -p tcp --dport 22 -j ACCEPT
-I FORWARD -p tcp --dport 7180 -j ACCEPT ( to access cloudera manager url)
-I FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT

Make sure firewall stopped in gust host(systemctl stop firewalld)

No comments:

Post a Comment