Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 379
  • Last Modified:

Firewall on single server RH7.0 - NIC <->modem

Running RH7.0 on an IntelliStation attached to  corp. LAN. via tr0 (9.xx.xx.xx). I have users who telnet into this Linux box via the LAN and use minicom/dip to dial out sl0 (ttyS0).
I want to setup a firewall on this server so that:

sl0:
All inbound requests on sl0 are denied.
All outbound requests on sl0 except telnet and ftp (port 20/21) are denied.

tr0:
All inbound requests on tr0 except telnet denied.
All outbound requests on tr0 except telnet and ftp are denied.
_______________________________
Would like your thoughts and examples on this.
0
dbusher
Asked:
dbusher
  • 5
  • 4
  • 2
  • +4
2 Solutions
 
ahoffmannCommented:
ipchains -A input -i sl0 -j DENY
ipchains -A output -i sl0 --dport ! 20:21 -j DENY
# similar for tr0
0
 
dbusherAuthor Commented:
In what file should this go so that it is in effect upon boot up?
0
 
ahoffmannCommented:
write a new rc-script started at boot.
I'm not familar with RH, but usualy this file is i /sbin/init.d or /etc/init.d, then you need a symlink to this file. See README in the directory.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
ahoffmannCommented:
you may manage rc-scripts with rctab
0
 
vsamtaniCommented:
RedHat doesn't have rctab, I believe. The best place to put the ipchains commands is at the end of /etc/rc.d/init.d/rc.local; this is the last startup script to be executed.

Vijay
0
 
dbusherAuthor Commented:
I just put my ipchain statement right on in that file? I'll give it a shot.
0
 
BlackDiamondCommented:
If you want the rules to apply after you restart, just apply the rules on the command line like ahoffman showed above.  You can then save them for the RC scripts by typing "service ipchains save" after you have everything working the way you want.  Voila...
0
 
ifinchamCommented:
Hi,

Don't think its quite as simple as that ! When you allow outbound packets you have to also allow the related inbound packets. Also FTP is a bit more complex because there is a client initiated connection on port 21 but then, for the data, a ftp-server initiated session from the server's port 20 that you have to allow in.

Firstly, 'flush' existing chain and set default :

ipchains -F
ipchains -P input DENY
ipchains -P output DENY
ipchains -P forward DENY


For telnet :

ipchains -A output -i tr0 -p tcp -d any/0 23 -j ACCEPT
ipchains -A input -i tr0 -p tcp ! -y -s any/0 23 -j ACCEPT

For 'normal mode' (not-passive) FTP ;

ipchains -A output -i tr0 -p tcp -d any/0 21 -j ACCEPT
ipchains -A input -i tr0 -p tcp ! -y -s any/0 21 -j ACCEPT
ipchains -A input -i tr0 -p tcp -s any/0 20 -d any/o 1024:65535 -j ACCEPT
ipchains -A output -i tr0 -p tcp ! -y -s any/0 1024:65535 -d any/0 20 -j accept

Obviously, I've just shown the rules for the token-ring interface above... (The '! -y' bit means check that SYN is not set, i.e.  its not an attempt to initiate a connection the other way round)

On storing the rules...

'/sbin/service ipchains save' will place the output into  '/etc/sysconfig/ipchains'. Redhat have a sysv init script called ipchains so you would activate that by setting run-levels 2345 on via 'ntsysv' or even simpler by the following command (as root)

/sbin/chkconfig --level 2345 ipchains on

An alternative would be simply to place the rules in the '/etc/rc.d/rc.local' script which is the last script run in the normal redhat boot sequence.

Regards



0
 
ifinchamCommented:
Hi,

Actually just noticed there was a difference with the tr0 interface in that you wanted to allow inbound.

THe following allows inbound telnet

ipchains -A input -i tr0 -p tcp -s any/0 1024:65535 -d any/0 23 -j ACCEPT
ipchains -A output -1 tr0 -p tcp ! -y -s any/0 23 -d any/0 1024:65535 -j ACCEPT

Also in case you want passive ftp :

ipchains -A output -i tr0 -p tcp -s any/0 1024:65535 -d any/0 1024:65535 -j ACCEPT
ipchains -A input -i tr0 -p tcp ! -y -s any/0 1024:65535 -d any/0 1024:65535 -j ACCEPT

In fact, you'd be better off substituting 'any/0' for your actual IP address ... For example using 172.16.16.1 as your linux box..

ipchains -A output -i tr0 -p tcp -s 172.16.16.1 1024:65535 -d any/0 1024:65535 -j ACCEPT
ipchains -A input -i tr0 -p tcp ! -y -s any/0 1024:65535 -d 172.16.16.1 1024:65535 -j ACCEPT

Regards

0
 
dbusherAuthor Commented:
I will be away for 2 weeks. I will give each of these a shot when I return.  Sorry for the delay
0
 
dbusherAuthor Commented:
My 2 weeks turned out to be much longer.  I will me in the office on the 23rd to give this a shot. If all goes well I will accept at the end of the week. Sorry for the delay and thanks for all the great help.
0
 
dbusherAuthor Commented:
ifincham,  it looks like this will allow inbound AND outbound telnet on tr0.  True? Or does the FLUSH take care of this?? Thanks.
Also, How do I reject ALL inbound requests on my modem port ttyS0? Which is sl0. Same type of commands??  Sorry, I am a newbie at this.
0
 
CleanupPingCommented:
dbusher:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
ahoffmannCommented:
except a typo (should be -o instead og -i in secind rule) my very first suggestion is still valid
0
 
troopernCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Split between ahoffmann & ifincham.
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

troopern
EE Cleanup Volunteer
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 5
  • 4
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now