LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 09-19-2003, 10:22 AM   #1
Johnnyboy
LQ Newbie
 
Registered: Sep 2003
Posts: 17

Rep: Reputation: 0
Iptables at startup


Hi, I'm fairly new to linux and I have a problem with starting up linux with ipforwarding. When I boot linux I always have to run these commands on linux to get my winXP box to connect to the Internet through my linux box.

iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface eth1 -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward

How can I make it so that I don't have to write these commands every single time I boot? I know that I should make some kind of startup script and so on, but can someone give me direct instructions what to do and how because I don't have a clue?

I have a similar problem with starting apache server at startup

/etc/rc.d/init.d/httpd start
 
Old 09-19-2003, 12:07 PM   #2
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 416Reputation: 416Reputation: 416Reputation: 416Reputation: 416
Writing a script is easy. You do have to start with [#! /bin/bash[/B] on the first line. That tells linux that this is a bash script, so if you use a shell besides bash, you may have to change it (I don't think many people do, so try it this way and see if it works).

On the following lines, just add the lines you normally type in the console. Once your done, save the file. In order to run the script, you have to make it executable, and you can do that by chmod +x scriptname.

Once you've got your script, you can either run in manually, or put a reference to it in a startup file like /etc/rc.local. For example, on my Slackware machine, I've got a firewall script called /etc/rc.firewall (which is the standard name in Slackware and a few other distros) and in the rc.inet1 file (which starts up the network in Slack) there is a line rc.firewall. So when the script hits that during boot, it starts my firewall.
 
Old 09-19-2003, 03:36 PM   #3
Johnnyboy
LQ Newbie
 
Registered: Sep 2003
Posts: 17

Original Poster
Rep: Reputation: 0
Thx a lot, that works!
 
  


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
slackware iptables startup Atrocity Slackware 4 07-01-2005 12:47 PM
iptables startup script vishamr2000 Linux - Security 3 04-29-2005 09:21 AM
Iptables Startup Ionmag Linux - Security 5 04-12-2005 12:01 AM
iptables startup script mushmaster Linux - General 12 02-25-2005 01:32 PM
curious iptables error on startup brutal_brad Linux - Laptop and Netbook 2 09-20-2003 06:20 PM


All times are GMT -5. The time now is 03:50 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