Hello there,
I created IPtables (including MASQUERADE) rules and saved it in a script to get it executed on startup by adding its record to bootlocal.sh.
Now the Internet interface eth0 is not getting up until I execute : sudo ifconfig eth0 up
, only then all works fine.
P.S: eth0 getting up ok when I start the machine without the IPtables rules script.
I think IPtables script execution should be delayed until etho is up ( something like putting it in /etc/network/if-up.d/ in Debian ).
Please, let me know how to do that in TLC?
# delete all existing rules.
#
iptables -F
iptables -t nat -F
iptables -t mangle -F
iptables -X
# Always accept loopback traffic
iptables -A INPUT -i lo -j ACCEPT
# Allow established connections, and those not coming from the outside
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -m state --state NEW -i ! eth1 -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow outgoing connections from the LAN side.
iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT
# Masquerade.
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
# Don't forward from the outside to the inside.
iptables -A FORWARD -i eth1 -o eth1 -j REJECT
# Enable routing.
echo 1 > /proc/sys/net/ipv4/ip_forward