Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 3237  / 3 Years ago, fri, october 1, 2021, 10:35:56

I am working on an experiment. When I (client) ssh into a gateway and run sudo iptables --policy INPUT DROPthen the gateway doesn't accept any communucation (or input) from my client.



By running sudo iptables --policy INPUT ACCEPT on the gateway, then the client is able to write again.



My question is: How can I restore the situation from the client?


More From » ssh

 Answers
6

There are two things you should do to keep that system accessible before changing netfilter-rules:




  1. create an exception in the firewall rules for ssh from your machine

  2. create a safeguard



create an exception



create an appropriate rule with iptables



sudo iptables -A INPUT -p tcp --dport ssh --source-address yourextIPadd -j ACCEPT


(where yourextIPadd is the IP address of your machine at home, seen from the outside)



or utilizing ufw



If you have ufw Install ufw installed already you can tell ufw to create an exception



sudo ufw allow from yourextIPadd to any port 22


create a safeguard



Before issuing the command to alter the default-policy for netfilter to DROP you can tell the system to revert that command after (say) 5 minutes with the handy command at



sudo at -vM now +5 minutes


now you are in something like an editor, where you can type commands to be executed later, you close/end that by typing CTRLD.



Type



/sbin/iptables --policy INPUT ACCEPT


CTRLD



You will see something like



sudo at -vM  now +1 minute
Fri Aug 29 17:46:00 2014

warning: commands will be executed using /bin/sh
at> /sbin/iptables iptables --policy INPUT ACCEPT
at> <EOT>
job 5 at Fri Aug 29 17:46:00 2014


Remarks




  • you need to call at with sudo (it must be root's at table)

  • therefore no need for sudo within

  • -v tells at to show the intended execution time when you are finished

  • -M tells at to send no e-mail regarding success/failure

  • for in-depth help with iptables have a look at the IPTables Howto


[#23439] Saturday, October 2, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bewre

Total Points: 164
Total Questions: 108
Total Answers: 106

Location: Ghana
Member since Sun, Mar 27, 2022
2 Years ago
;