I want to block a ip from accessing wan, only lan
I used from GUI: Firewall => Network services filter
I added two rules( as seen in /tmp/filter_rules) that work
-A FORWARD -i br0 -o eth0 -p udp -s 192.168.1.99 -j DROP
-A FORWARD -i br0 -o eth0 -p tcp -s 192.168.1.99 -j DROP
However I want to be able to somewhat easy turn these on and off.
My thinking was to run a script via ssh to do this.
I guess those lines above with "iptables" in front of them are what adds
the restriction for that ip.
resulting in iptables -L these two lines
DROP udp -- tv1dd1ac16b520 anywhere
DROP tcp -- tv1dd1ac16b520 anywhere
1.
My question is could I add the rules directly with the hostname tv1dd1ac16b520
instead of ip-address so I don't have to make that adress static?
Do I have to insert at a certain line number for it to work?
How would such a command look?
2.
What is the command to remove these two rules again
*edit*
I could possibly use
iptables -L FORWARD -n --line-numbers | grep 192.168.1.99 | cut -d' ' -f1
to get the linenumbers to delete with
iptables -D FORWARD #linenumber
Here I have to use ip to and not hostname? could this be changed?
Could I delete in another easier way?
3.
Do I have to save/commit updates to iptable with iptable-save?
4.
Maybe I could manipulate the file /tmp/filter_rules instead and then save/commit that somehow
Any help would be most welcome
I used from GUI: Firewall => Network services filter
I added two rules( as seen in /tmp/filter_rules) that work
-A FORWARD -i br0 -o eth0 -p udp -s 192.168.1.99 -j DROP
-A FORWARD -i br0 -o eth0 -p tcp -s 192.168.1.99 -j DROP
However I want to be able to somewhat easy turn these on and off.
My thinking was to run a script via ssh to do this.
I guess those lines above with "iptables" in front of them are what adds
the restriction for that ip.
resulting in iptables -L these two lines
DROP udp -- tv1dd1ac16b520 anywhere
DROP tcp -- tv1dd1ac16b520 anywhere
1.
My question is could I add the rules directly with the hostname tv1dd1ac16b520
instead of ip-address so I don't have to make that adress static?
Do I have to insert at a certain line number for it to work?
How would such a command look?
2.
What is the command to remove these two rules again
*edit*
I could possibly use
iptables -L FORWARD -n --line-numbers | grep 192.168.1.99 | cut -d' ' -f1
to get the linenumbers to delete with
iptables -D FORWARD #linenumber
Here I have to use ip to and not hostname? could this be changed?
Could I delete in another easier way?
3.
Do I have to save/commit updates to iptable with iptable-save?
4.
Maybe I could manipulate the file /tmp/filter_rules instead and then save/commit that somehow
Any help would be most welcome
Last edited: