I have to setup firewall rules for my onboard network(for list of device which are connected via eth0
interface) during boot up of Linux device.
By default all communication over eth0
should be disabled.
Then read configuration file (conf.xml
) which contains ipaddress or URL or port those are only allowed to do communication means only whitelisted devices can do communication.
I have done it in following way but it not works as expected
Default - Disabled eth0
communication using
sudo iptables -A INPUT -i eth0 -j DROP
Then For example. enabled FTP access for a Specific IP mentioned in configuration file (conf.xml
) using below command
iptables -A INPUT -p tcp -s 10.10.10.10 --dport 21 -j ACCEPT
But i see eth0
communication is permanently disabled and it even not allow ipaddress 10.10.10.10
to access FTP server.
Edit: As per answer i have modified script as below
Added below two lines at start
iptables -A INPUT -p tcp -s 10.10.10.10 --dport 21 -i eth0 -j ACCEPT
iptables -A OUTPUT -p tcp -s 10.10.10.10 --dport 21 -o eth0 -j ACCEPT
then added below two lines at the end of script
iptables -A INPUT -i eth0 -j DROP
iptables -A OUTPUT -o eth0 -j DROP
still i am facing issue to access of FTP using IP iptables -A INPUT -i eth0 -j DROP