LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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-2009, 11:07 AM   #1
nelgin
LQ Newbie
 
Registered: Nov 2009
Posts: 8

Rep: Reputation: 0
iptables + WAN and LAN per user


Greets all, first time poster here.

I have a Linux server that has two network interfaces
eth0 has a direct connection to the internet with a static IP address
eth1 is a 192.168.x.x network to the local LAN.

I allow some external internet users shell access to the system, however, not all of them should be able to access the LAN.

I'm pretty sure iptables can now do per-user blocking, but I'm not sure what the rule would be.

For example, say that eth0 is 70.70.70.70 (for ease of use) and eth1 is 192.168.1.5 and I have three users, Fred, John and Albert. I would like Albert to be able to access anything on the 192.168.x.x network as well as the internet, and John and Fred only have access to the internet.

How would I implement that in iptables?

Thanks,
Nigel
 
Old 11-23-2009, 11:47 AM   #2
Jim Bengtson
Member
 
Registered: Feb 2009
Location: Iowa
Distribution: Ubuntu 9.10
Posts: 164

Rep: Reputation: 38
Quote:
For example, say that eth0 is 70.70.70.70 (for ease of use) and eth1 is 192.168.1.5 and I have three users, Fred, John and Albert. I would like Albert to be able to access anything on the 192.168.x.x network as well as the internet, and John and Fred only have access to the internet.
Are John, Fred, and Albert already inside your network, or are they trying to access your network from the internet? If they're inside your network then your firewall server won't block John and Fred from accessing a server in your network. You'd have to configure ipTables on those servers to accept connections from Albert's IP address and to not accept connections from John and Fred's IP addresses. And that would work only so long as John, Fred and Albert did not change their IP address.

Or you could use something like openLDAP and PAM to force Albert, John and Fred to authenticate with the server, and then not allow John and Fred to get in once authenticated.

If they're all outside your network, then you can configure your firewall server to block all IP addresses except Albert's, but that would work only so long as Albert kept that IP address. Or you could use Radius to allow authenticated access through your firewall based on username and password, rather than IP address. You can even integrate Radius, openLDAP and PAM together so that Radius challenged users at the firewall, using the directory data in openLDAP to only let Albert, John and Fred through the firewall, and then use the pam_ldap PAM module to have the servers authenticate users against the same openLDAP directory, so that Albert is allowed access to the server but Fred and John are denied access.

openLDAP: http://www.openldap.org/
PAM: http://www.kernel.org/pub/linux/libs/pam/
Radius: http://freeradius.org/

Centralized Logins Using LDAP and RADIUS: http://www.linuxhomenetworking.com/w...DAP_and_RADIUS
 
Old 11-23-2009, 03:09 PM   #3
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by nelgin View Post
Greets all, first time poster here.

I have a Linux server that has two network interfaces
eth0 has a direct connection to the internet with a static IP address
eth1 is a 192.168.x.x network to the local LAN.

I allow some external internet users shell access to the system, however, not all of them should be able to access the LAN.

I'm pretty sure iptables can now do per-user blocking, but I'm not sure what the rule would be.

For example, say that eth0 is 70.70.70.70 (for ease of use) and eth1 is 192.168.1.5 and I have three users, Fred, John and Albert. I would like Albert to be able to access anything on the 192.168.x.x network as well as the internet, and John and Fred only have access to the internet.

How would I implement that in iptables?

Thanks,
Nigel
Here's an example of how you could do it (sans context):
Code:
iptables -A OUTPUT -o eth0 -j ACCEPT
iptables -A OUTPUT -o eth1 -m owner --uid-owner Albert -j ACCEPT
iptables -A OUTPUT -o eth1 -j REJECT
That's pretty much the gist of it (let me know if you have any questions).

BTW, welcome to LQ!

Last edited by win32sux; 11-23-2009 at 03:12 PM.
 
Old 11-23-2009, 11:12 PM   #4
nelgin
LQ Newbie
 
Registered: Nov 2009
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Jim Bengtson View Post
Are John, Fred, and Albert already inside your network, or are they trying to access your network from the internet? If they're inside your network then your firewall server won't block John and Fred from accessing a server in your network. You'd have to configure ipTables on those servers to accept connections from Albert's IP address and to not accept connections from John and Fred's IP addresses. And that would work only so long as John, Fred and Albert did not change their IP address.
They have ssh access to the server so will have a physical shell on 70.70.70.70. I would only want certain people to have access to other servers on the 192.168.x.x network. Albert, for example, would have access to any NFS mounts, Samba shares, network printers, ssh to other hosts on the internet network etc. The other users shouldn't even be able to send a ping down eth1.
 
Old 11-23-2009, 11:13 PM   #5
nelgin
LQ Newbie
 
Registered: Nov 2009
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by win32sux View Post
Here's an example of how you could do it (sans context):
Code:
iptables -A OUTPUT -o eth0 -j ACCEPT
iptables -A OUTPUT -o eth1 -m owner --uid-owner Albert -j ACCEPT
iptables -A OUTPUT -o eth1 -j REJECT
That's pretty much the gist of it (let me know if you have any questions).

BTW, welcome to LQ!
Hmm, that looks almost too simple to be true I'll go ahead and give it a try.

Thanks for the welcome.

I'm pretty proficient with Linux, but I can never get my head around iptables. It doesn't delve deep enough into the security side often enough.
 
Old 11-24-2009, 01:03 AM   #6
nelgin
LQ Newbie
 
Registered: Nov 2009
Posts: 8

Original Poster
Rep: Reputation: 0
Thanks, win32sux. I just gave it a try by opening up a PC's remote desktop connection. I can telnet to the port as one user but not ask the blocked user. Thanks for your help.
 
Old 11-24-2009, 07:45 AM   #7
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Sounds like you've got it working, given the telnet test results. Let me know if you hit any snags.
 
  


Reply

Tags
iptables



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
iptables help - 1 wan - 2 lan sganesh_1975 Linux - Networking 13 08-06-2009 08:46 AM
Maintaining user accounts across several machines (not LAN/WAN) rjlee Linux - Software 1 02-20-2009 02:46 PM
LAN cannot access other LAN systems, only WAN Myrion Linux - Networking 1 09-06-2007 07:29 PM
LAN but no WAN BCarey Linux - Networking 4 05-07-2006 12:24 PM
Routing LAN -> WAN -> LAN with unhelpful router synx13 Linux - Networking 2 06-14-2004 02:35 PM

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

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