LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 01-31-2009, 08:43 AM   #1
andreirp
LQ Newbie
 
Registered: Jan 2009
Posts: 6

Rep: Reputation: 0
Output conection Public IP - Iptables, Route Rules


Hi,


My problem is that the users of my intranet, access a system (site) via internet that does ip control conection. I was MASQUERADING the intranet address through only one Public IP. However by the large number of intranet users accessing the system (site) through unique Public IP, the system(site) blocked our Public IP claiming much conections by the same Public IP.
I get a range of Public IPs to use in this solution. Someone knows how do I to randomly release the Public IPs, then, the IP conection output of intranet users would be different each time that the users access the system (site), using my range of Public IP address.
Via software at linux, using iptables, route rules or other method, would be possible do this ?


Someone could help me ?

Thanks

Andrei
 
Old 01-31-2009, 01:09 PM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Just brainstorming here: how many internal end-users are we talking about? One solution may be subnetting them into groups, where each group is NAT'ed behind a different Linux gateway w/ a public IP.
 
Old 02-01-2009, 06:45 PM   #3
andreirp
LQ Newbie
 
Registered: Jan 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks Answering my question !

I will have around 200 users accessing this system, i get 64 public IP to use and i would like to use only one gateway. My idea was find some method to randomly release the 64 public IP only at output conection, after MASQUERADE, but i dont know if iptables or there is other method to do this. I must have many gateways to subnetting into groups, i would like to randomly release the 64 public IP that i have if possible with just one gateway.

Thanks a lot for helping me.

Andrei
 
Old 02-02-2009, 10:08 AM   #4
rossonieri#1
Member
 
Registered: Jun 2007
Posts: 359

Rep: Reputation: 34
hi andrei,

Quote:
I was MASQUERADING the intranet address through only one Public IP. However by the large number of intranet users accessing the system (site) through unique Public IP, the system(site) blocked our Public IP claiming much conections by the same Public IP.
i think that -SNAT could do the trick like :
Code:
iptables -t nat -A POSTROUTING -s <LAN_IP_subnet> -o <internet_intf> -j SNAT --to-source <lower_public_IP>-<higher_public_IP>
the port is optional but is important.

HTH.
 
Old 02-03-2009, 04:29 AM   #5
andreirp
LQ Newbie
 
Registered: Jan 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Hi rossonieri,

Thanks Answering my question !


I have a doubt,

iptables -t nat -A POSTROUTING -s <LAN_IP_subnet> -o <internet_intf> -j SNAT --to-source <lower_public_IP>-<higher_public_IP>

In my interface, would i have to have all Public IPs, setting in my
-o <internet_intf> , or just one ?

eth0 - 1 Public IP
eth0:0 - 2 ..
eth1:1 - 3 ..

etc..

Thanks

Andrei
 
Old 02-03-2009, 08:50 AM   #6
rossonieri#1
Member
 
Registered: Jun 2007
Posts: 359

Rep: Reputation: 34
hi andrei,

Quote:
In my interface, would i have to have all Public IPs, setting in my
-o <internet_intf> , or just one ?

eth0 - 1 Public IP
eth0:0 - 2 ..
eth1:1 - 3 ..
no - you dont need to create a sub/logical/alias-interface (eg. eth0:1 etc)for the outgoing connection (but is optional) & AFAIK it will not work on both iptables -SNAT or -MASQ.

you just need to put those ip-public-pool (lower_public_IP & higher_public_IP) for that single interface and do SNAT.

eq.
Code:
iptables -t nat -A POSTROUTING -o <internet_interface> -j SNAT --to-source a.b.c.d-a.b.c.g
HTH.
 
Old 02-04-2009, 04:10 AM   #7
andreirp
LQ Newbie
 
Registered: Jan 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Thankss rossonieri, i get now !! i will try

When every time that user access the system the SNAT --to-source a.b.c.d-a.b.c.g randomly release the Public IPs, the system will receive each time a different Public IP, its ok?

Thanksss rossonieri for help me !

Andrei
 
Old 02-04-2009, 04:43 AM   #8
rossonieri#1
Member
 
Registered: Jun 2007
Posts: 359

Rep: Reputation: 34
hi andrei,

Quote:
When every time that user access the system the SNAT --to-source a.b.c.d-a.b.c.g randomly release the Public IPs, the system will receive each time a different Public IP, its ok?
nice question
surely it still does have a drawback.
in connection oriented session - for example like users were chatting using yahoo! messenger, and in the middle of email writing - if any previous IP that used to be use to connect to the server get idle - the router will swap the IP for other user connection & the current user get their IP change - the server will reject them (your previous session). but it will do just fine for regular internet browsing.

if you dont like this idea - then to over come this problem is 1 to 1 NAT mapping = 1 public IP for 1 client. still use the same SNAT technique - but it is a hard work

HTH.
 
Old 02-06-2009, 08:59 AM   #9
andreirp
LQ Newbie
 
Registered: Jan 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Hi rossonieri,

I try this solution with SNAT, but my MASQUERADE conection doesnt work !


Before i had the iptables RULE with iptables ..... -j MASQUERADE and i changed to -j SNAT ......-.....

i have to have the MASQUERADE too ?


Thankss rossonieri !!


Andrei
 
Old 02-06-2009, 10:40 AM   #10
rossonieri#1
Member
 
Registered: Jun 2007
Posts: 359

Rep: Reputation: 34
hi andrei,

Quote:
I try this solution with SNAT, but my MASQUERADE conection doesnt work !
there is either you use the iptables -t nat -A POSTROUTING -j SNAT, or use the -j MASQ, can not use both. you can not use multiple public IP addresses using MASQ (it only multiply connections by ports), so the only way is using SNAT which allows you to multiply by IP addresses also.

or you can post your config here so we can help you.

HTH.
 
Old 02-09-2009, 03:59 AM   #11
andreirp
LQ Newbie
 
Registered: Jan 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Hi rossonieri,

thanks more one time,

In my rule i have, The Forward rule and the SNAT.

Quote:
Iptables -A FORWARD -s IntranetIP -j ACCEPT
Iptables -A FORWARD -d IntranetIP -j ACCEPT
Quote:
iptables -t nat -A POSTROUTING -s IntranetIP/24 -o eth0 -j SNAT --to-source A.B.C.D-A.B.C.G
But the internet doesn't work.

is there something else to do ?

Thankss

Andrei
 
  


Reply



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
Script to Load Balance two ISPs with ip route & ip rules niels.horn Slackware 12 08-07-2015 01:13 AM
iptables 1.27a still loading rules after installing iptables 1.3.0 yawe_frek Linux - Software 1 06-07-2007 09:50 PM
sharing conection (iptables) problem TiCkO Slackware 1 01-13-2005 02:30 PM
Creating a Server [with ability to route cable conection] Wolfy Linux - Networking 1 07-07-2004 10:04 PM
iptables OUTPUT rules: DROP by process (PID)? gregory76 Linux - Security 6 07-11-2003 04:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:10 PM.

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