I have a virtual machine that works like a gateway from other virtual machines.
The configuration of the interfaces is the following
UBUNTU:
eth0:
ip: 10.0.2.2
netmask 255.255.255.255
gateway 10.0.2.2
eth1:
ip: 192.168.1.1
bcast: 192.168.1.255
netmask: 255.255.255.0
I would like to close all the ports and to surf over internet only with the gateway.
Without rules it works perfectly, but with the actual firewall configuration iptables blocks the connection.
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -A OUTPUT -o eth0 -p tcp --dport 80 -m state -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --sport 80 -m state -j ACCEPT
iptables -A FORWARD -i eth1 -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# ..... other rules for the others connected vm