LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-12-2012, 07:07 AM   #1
jaskobih
LQ Newbie
 
Registered: Apr 2012
Posts: 2

Rep: Reputation: Disabled
iptables script


Hello i have a problem with iptables on my ubuntu i try to build a script that will close port like this.

iptables -A INPUT -p tcp --dport 2000 -j DROP

I nee to know ho to add this to auto start after i reboot my linux?
I dont want to add evry time manual after reboot.

Regards!
 
Old 04-12-2012, 08:47 AM   #2
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,300

Rep: Reputation: 102Reputation: 102
See if this link is suitable for you.
 
Old 04-12-2012, 09:15 AM   #3
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,629

Rep: Reputation: Disabled
You execute the iptables command and then save the iptables using /etc/init.d/iptables save or similar command and start the iptables service to run at boot. This will make the firewall changes persistent across boots and you would not require add the entry in firewall every time system boots.
 
Old 04-12-2012, 02:37 PM   #4
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,415

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
After executing the iptables command you just need to save the rule you defined to close the port.

Code:
$ sudo sh -c "iptables-save > /etc/iptables.rules"
 
Old 04-12-2012, 04:00 PM   #5
jaskobih
LQ Newbie
 
Registered: Apr 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
@Satyaveer thanks it works!
Regards
 
Old 04-12-2012, 04:08 PM   #6
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,415

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
Glad to know it worked for you. If your problem has been solved you can mark this thread as SOLVED.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Looking for iptables script JosephS Slackware 15 07-13-2009 11:24 PM
iptables-save, iptables-restore, how to set up them in some script sarajevo Linux - Networking 1 03-25-2008 12:39 AM
Iptables (with masq) troubleshooting, very simple script attached script and logs. xinu Linux - Networking 13 11-01-2007 05:19 AM
IPTABLES script help closer Linux - Networking 18 11-04-2002 10:48 AM
My iptables script is /etc/sysconfig/iptables. How do i make this baby execute on boo ForumKid Linux - General 3 01-22-2002 08:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:27 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration