LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 11-23-2023, 03:14 PM   #1
chrisknight
Member
 
Registered: Jan 2003
Location: ohio
Distribution: CentOS7.6
Posts: 157

Rep: Reputation: 15
make offline iptables rule stick after reboot


Hi! I've got an older CentOS 6.10 box.
I cannot issue commands to this box while it is running, but I can boot it with Fedora Live and access the file system. I want to be able to add something like
"iptables -A INPUT -p tcp --dport 22 --source 192.168.3.0/24 -j ACCEPT" to "/etc/sysconfig/iptables" so I can SSH into it but when I do, it does not survive a boot/reboot. At the top it says "# Generated by iptables-save v1.4.7 on some date..." Where is the source for what iptables-save is populating on boot? Or how else can I make the rule survive a boot? I tried to add it into "/etc/rc.d/rc.local" but that didn't work.
Thanks!
 
Old 11-23-2023, 04:26 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,777

Rep: Reputation: 5935Reputation: 5935Reputation: 5935Reputation: 5935Reputation: 5935Reputation: 5935Reputation: 5935Reputation: 5935Reputation: 5935Reputation: 5935Reputation: 5935
Run the command after the all your rules are entered as root

service iptables save
 
Old 11-24-2023, 06:13 AM   #3
chrisknight
Member
 
Registered: Jan 2003
Location: ohio
Distribution: CentOS7.6
Posts: 157

Original Poster
Rep: Reputation: 15
Thank you for the reply. I cannot do that since I don't have console access. I need to do it offline by accessing the file system with another OS.
 
Old 11-24-2023, 08:31 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,777

Rep: Reputation: 5935Reputation: 5935Reputation: 5935Reputation: 5935Reputation: 5935Reputation: 5935Reputation: 5935Reputation: 5935Reputation: 5935Reputation: 5935Reputation: 5935
If you have physical access you should be able to acquire console access. What is the problem?

The -A appends a rule to the bottom. Without knowing the complete ruleset it is impossible to know why using rc.local does not work. You could create all new rules from rc.local or stop the rules from being loaded which should allow all traffic.

Last edited by michaelk; 11-24-2023 at 09:07 AM.
 
Old 11-24-2023, 11:28 AM   #5
chrisknight
Member
 
Registered: Jan 2003
Location: ohio
Distribution: CentOS7.6
Posts: 157

Original Poster
Rep: Reputation: 15
I do have physical access, but the console interface is broken.
I had to start the sshd service in rc.local as well with the firewall rule. Kind of a slap forehead moment. Haha! I got it going.
Thanks for your time!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How To Fully Update And Upgrade Offline Debian-based Systems Using Apt-offline LXer Syndicated Linux News 0 09-20-2022 02:03 PM
[SOLVED] apt-offline fails to install updates to offline computer with ERROR: Failed to unlink /var/lib/apt/lists/partial/ JoLinuxUser Ubuntu 9 09-12-2019 08:11 AM
[SOLVED] Why does iptables rule doesn't get set after a reboot once in a while gprathap1121@gmail.com Linux - Security 13 06-23-2014 04:41 AM
iptables: rule with RETURN target just after a rule with ACCEPT target Nerox Linux - Networking 6 09-04-2011 03:33 PM
I can't make screen size changes "stick" -- they're always set back after a reboot PTrenholme Ubuntu 15 02-29-2008 06:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 05:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration