Skip to contentSkip to conversation

Core Linux Router - NO NAT

DISCUSSION Mark Seamans 4 participants 5 messages Mar 20, 2003 – Mar 21, 2003

lore
Share & tools
lore
#0 lore raw

I have a Linux router that consists of 4 T1ports and 1 ethernet. This "Router" will act as an ISP core router doing Routing Only! I wish to protect the box itself, while it preforms it's duties as a Router allowing only ssh from the ip's that I wish for management. This way I can also setup rules to protect it form DOS attacks etc...
Now I have been thinking of this, but I can go two ways:
1. Making it harder than it really is -OR-
2. Allowing it to be so easy it is not secure.

So any suggestions would be great.

Thanks!

Mark
[email protected]

#1 lore raw
Quoted 9 lines · Mark Seamans

I have a Linux router that consists of 4 T1ports and 1 ethernet. This "Router" will act as an ISP core router doing Routing Only! I wish to protect the box itself, while it preforms it's duties as a Router allowing only ssh from the ip's that I wish for management. This way I can also setup rules to protect it form DOS attacks etc... Now I have been thinking of this, but I can go two ways:
1. Making it harder than it really is -OR-
2. Allowing it to be so easy it is not secure.

Quoted 6 lines

So any suggestions would be great.

Thanks!

Mark
[email protected]

For the basic task of restricting access to the routing box itself, and allowing only SSH connections from designated IPs:

iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -N SSHLOG
iptables -A SSHLOG -j LOG --log-level debug --log-prefix "Router SSH Access:"
iptables -A SSHLOG -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -s a.b.c.d -j SSHLOG {repeat last rule as needed for different authorized IPs}

Another approach might be to have only one or two IPs from which you allow SSH connections. Then if you need to connect from a remote client, SSH to the authorized client, (an admin box at the office?) then SSH from that client to the router. (I use this approach to SSH to my home desktop - which cannot be directly reached from the internet - by first initiating an SSH session to my gateway from one of the IPs from which IT will accept an SSH connection)

If your usage will permit, you can match more closely in the INPUT rules by also restricting to input on a particular interface. This is made more likely if you use the double-SSH approach above, the main reason I mentioned it.

You can change /etc/syslog.conf to add a new target like:
kern.=debug /var/log/firewall
or even set it up for remote logging with
kern.=debug @remotelogginghostname
(this would make it much harder for someone who has compromised the box to cover their tracks, and would require an additional OUTPUT rule ACCEPTing UDP dport 514 to the designated logging host)

j

#2 lore raw

So, this will allow all routing between all interfaces to all networks but only allowing host 1.2.3.4 have access to ssh?
See! I was going to make it too hard. I do appreciate the tip. I will be doing this on a production box for an ISP 1600 miles away with little room for error.

-----Original Message-----

Quoted 9 lines · Mark Seamans

I have a Linux router that consists of 4 T1ports and 1 ethernet. This "Router" will act as an ISP core router doing Routing Only! I wish to protect the box itself, while it preforms it's duties as a Router allowing only ssh from the ip's that I wish for management. This way I can also setup rules to protect it form DOS attacks etc... Now I have been thinking of this, but I can go two ways:
1. Making it harder than it really is -OR-
2. Allowing it to be so easy it is not secure.

Quoted 6 lines

So any suggestions would be great.

Thanks!

Mark
[email protected]

For the basic task of restricting access to the routing box itself, and allowing only SSH connections from designated IPs:

iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -N SSHLOG
iptables -A SSHLOG -j LOG --log-level debug --log-prefix "Router SSH Access:"
iptables -A SSHLOG -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -s a.b.c.d -j SSHLOG {repeat last rule as needed for different authorized IPs}

Another approach might be to have only one or two IPs from which you allow SSH connections. Then if you need to connect from a remote client, SSH to the authorized client, (an admin box at the office?) then SSH from that client to the router. (I use this approach to SSH to my home desktop - which cannot be directly reached from the internet - by first initiating an SSH session to my gateway from one of the IPs from which IT will accept an SSH connection)

If your usage will permit, you can match more closely in the INPUT rules by also restricting to input on a particular interface. This is made more likely if you use the double-SSH approach above, the main reason I mentioned it.

You can change /etc/syslog.conf to add a new target like:
kern.=debug /var/log/firewall
or even set it up for remote logging with
kern.=debug @remotelogginghostname
(this would make it much harder for someone who has compromised the box to cover their tracks, and would require an additional OUTPUT rule ACCEPTing UDP dport 514 to the designated logging host)

j

#4 lore raw
In reply to Mark Seamans

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 3 lines · Mark Seamans

I have a Linux router that consists of 4 T1ports and 1 ethernet. This "Router" will act as an ISP core router doing Routing Only! I wish to protect the box itself, while it preforms it's duties as a

Router

Quoted 1 line

allowing only ssh from the ip's that I wish for management. This way

I can

Quoted 6 lines

also setup rules to protect it form DOS attacks etc... Now I have been thinking of this, but I can go two ways:
1. Making it harder than it really is -OR-
2. Allowing it to be so easy it is not secure.

So any suggestions would be great.

Newer versions of ssh will honor the hosts.allow and hosts.deny files, so you might want to make sure that hosts.allow only lets sshd connections from the IP's you are interested in. Just make sure you do a ALL : ALL in hosts.deny so that no other services can get to the box that you haven't allowed in hosts.allow.

Note: there are services that don't use the hosts.allow/deny files (apache for example) so you need to make sure you don't have anything uneeded running.

You could do this without needing to setup firewall rules, but then it becomes harder to limit DOS attacks, etc.

- --
James A. Pattie
[email protected]

Linux -- SysAdmin / Programmer
Xperience, Inc.
http://www.pcxperience.com/
http://www.xperienceinc.com/

GPG Key Available at http://www.pcxperience.com/gpgkeys/james.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+ey2KtUXjwPIRLVERAiQAAJ9QL0671K+msi/BdVwL+pS2UmQXRACg2w28 MJVVHt8CEYPu1h3boVkvjpI=
=RgM/
-----END PGP SIGNATURE-----

Signature · 3 lines
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
#3 lore raw
In reply to Joel Newkirk
Quoted 10 lines · Joel Newkirk
Quoted 6 lines · Mark Seamans

I wish to protect the box itself, while it preforms it's duties as a Router allowing only ssh from the ip's that I wish for management. This way I can also setup rules to protect it form DOS attacks etc...

So any suggestions would be great.

Another approach might be to have only one or two IPs from which you allow SSH connections. Then if you need to connect from a remote

I've seen the argument made that ssh should be configured only to authenticate with rsa keys.

(PasswordAuthentication no)

It makes it impossible for someone to try guessing passwords. Whether or not you can keep your key secure is another matter. Also, running ssh on another port, say port 25 or 80 will help you evade some of the automated scanning tools.

Kelly

--
Kelly Setzer, System Administrator/Architect - Placemark Investments 14180 Dallas Pkwy, Suite 200, Dallas, TX 75240 [email protected] http://www.placemark.com
(972)404-8100x41 (work) (214) 287-3464 (cell)