NAT with iptables / linux
Hello people!
I just buy my first 16 static ip pack and I am wondering what can I do to assign these ips to some workstation that I have. Something like this
=========
= =
= Lan = == Linux Box === Modem/router === Internet >>>
= =
=========
Lets say I have local ips like 10.0.0.0/24 and "real" static ips like 195.170.2.1 , 195.170.2.2 and so on....
And I want for every local ip to assing a static one.
In a few words I want every single workstation to have its own static ip.. A friend of mine told to that I have to use POSTROUTING and PREROUTING and here is that I confused...
Anyone can help me / tell me what exactly have to do to make this work ?
Thanks in advance and forgive me for my awful english :-)
Christos Panagiotakis
Quoted 4 lines
I just buy my first 16 static ip pack and I am wondering what can I do to assign these ips to some workstation that I have. Something like this
Quoted 8 lines
=========
= =
= Lan = == Linux Box === Modem/router === Internet >>> =
= =========Lets say I have local ips like 10.0.0.0/24 and "real" static ips like 195.170.2.1 , 195.170.2.2 and so on....
And I want for every local ip to assing a static one.
You might want to use the NETMAP target for this :
http://www.netfilter.org/patch-o-matic/pom-base.html#pom-base-NETMAP
(Yes : if you don't have this module already, you have to patch and compile your own kernel and iptables.)
Quoted 6 lines
In a few words I want every single workstation to have its own static ip..
A friend of mine told to that I have to use POSTROUTING and PREROUTING and here is that I confused...
Anyone can help me / tell me what exactly have to do to make this work ?
There is an example in the above url.
But, if you are confused by this then I think you also want to read up in Oskars tutorial...
http://iptables-tutorial.frozentux.net/iptables-tutorial.html
Gr,
Rob
Maybe this will help.
http://home1.gte.net/res0psau/security/nat-on-linux.html
Signature · 48 lines
kelly http://home1.gte.net/res0psau/index.html#Hang-Gliding-Stuff -- -- \ / \/ /\ / \ -- -- Quoting Rob Sterenborg <[email protected]>: > I just buy my first 16 static ip pack and I am wondering what can I do > to assign these ips to some workstation that I have. > Something like this > > ========= > = = > = Lan = == Linux Box === Modem/router === Internet >>> = > = ========= > > Lets say I have local ips like 10.0.0.0/24 and "real" static ips like > 195.170.2.1 , 195.170.2.2 and so on.... > And I want for every local ip to assing a static one. You might want to use the NETMAP target for this : http://www.netfilter.org/patch-o-matic/pom-base.html#pom-base-NETMAP (Yes : if you don't have this module already, you have to patch and compile your own kernel and iptables.) > In a few words I want every single workstation to have its > own static ip.. > A friend of mine told to that I have to use POSTROUTING and PREROUTING > and here is that I confused... > Anyone can help me / tell me what exactly have to do to make > this work ? There is an example in the above url. But, if you are confused by this then I think you also want to read up in Oskars tutorial... http://iptables-tutorial.frozentux.net/iptables-tutorial.html Gr, Rob
A message that is not in the archive (sent off-list or not yet received): 20060131174822.GA2760@[email protected]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 6 lines · kelly
Maybe this will help.
This is an interesting paper, wish I'd have found it when putting up the 1:! NAT system I have in place. Wondering though, can someone clarify for me why the secondary param is listed in the paper with significance? I was never informed of and have not made use of the ip add addr <dev> secondar....
Thanks,
Ron DuFresne
- -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
admin & senior security consultant: sysinfo.com
http://sysinfo.com
Key fingerprint = 9401 4B13 B918 164C 647A E838 B2DF AFCC 94B0 6629
...We waste time looking for the perfect lover
instead of creating the perfect love.
-Tom Robbins <Still Life With Woodpecker>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFD4Rt6st+vzJSwZikRApG3AKCGu4oxqO9q5fOqQ0P9JZ7xmT9kWwCgvEKS R1Ja85KU4knftUm7Nc/+tpI=
=8rsK
-----END PGP SIGNATURE-----
I'm not sure if I'm addressing your question or not, but I'll take a stab at what I *_think_* you're refering to.
The secondary IP address is a way of telling an interface to accept (and send) packets on more than one IP segment. It's the iproute2 utilities way of doing the same thing as the ifconfig option with the colon (sub-interface).
i.e. eth0 eth0:1
For instance, if you have a private IP segment (RFC 1918) between the firewall and the border router (the border router connects your network to the Internet in this case) -- i.e., 10.x.x.x --. This private segment cannot be advertised to the Internet.
Therefore you can add a secondary IP address to the firewall's ethernet interface. The secondary IP address is a public IP that *_CAN_* be advertised to the Internet. This same IP is the IP you want to create a *_STATIC NAT_* to. Be aware this is not a *_PAT_* (Port Address Translation).
The difference between a *_Static NAT_* and a *_PAT'd NAT_* is important. The Static NAT allows hosts from the *_OUTSIDE_* (i.e., the Internet) to establish a connection to the NAT'd host. Where as, with a *_PAT_*, the outsides hosts *_CANNOT_* establish connections (to a PAT'd host).
So the Internet border router needs to advertise the NAT IP (or the network containing the NAT IP) to the internet. But it also has to have a route that sends all traffic destined for that NAT IP (or Network) to the firewall's interface. This can be a static route.
HTH,
kelly
Signature · 15 lines
kelly http://home1.gte.net/res0psau/index.html#Hang-Gliding-Stuff -- -- \ / \/ /\ / \ -- -- Quoting R. DuFresne <[email protected]>: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Tue, 31 Jan 2006, kelly wrote:
>Maybe this will help.
>
>http://home1.gte.net/res0psau/security/nat-on-linux.html
>
>
>
This is an interesting paper, wish I'd have found it when putting up the
1:! NAT system I have in place. Wondering though, can someone clarify for
me why the secondary param is listed in the paper with significance? I
was never informed of and have not made use of the ip add addr <dev>
secondar....
Thanks,
Ron DuFresne
- --
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
admin & senior security consultant: sysinfo.com
http://sysinfo.com
Key fingerprint = 9401 4B13 B918 164C 647A E838 B2DF AFCC 94B0 6629
...We waste time looking for the perfect lover
instead of creating the perfect love.
-Tom Robbins <Still Life With Woodpecker>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFD4Rt6st+vzJSwZikRApG3AKCGu4oxqO9q5fOqQ0P9JZ7xmT9kWwCgvEKS
R1Ja85KU4knftUm7Nc/+tpI=
=8rsK
-----END PGP SIGNATURE-----A message that is not in the archive (sent off-list or not yet received): 20060201202635.GF1515@[email protected]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 36 lines · kelly
I'm not sure if I'm addressing your question or not, but I'll take a stab at what I *_think_* you're refering to.
The secondary IP address is a way of telling an interface to accept (and send) packets on more than one IP segment. It's the iproute2 utilities way of doing the same thing as the ifconfig option with the colon (sub-interface).
i.e. eth0 eth0:1For instance, if you have a private IP segment (RFC 1918) between the firewall and the border router (the border router connects your network to the Internet in this case) -- i.e., 10.x.x.x --. This private segment cannot be advertised to the Internet.
Therefore you can add a secondary IP address to the firewall's ethernet interface. The secondary IP address is a public IP that *_CAN_* be advertised to the Internet. This same IP is the IP you want to create a
*_STATICNAT_* to. Be aware this is not a *_PAT_* (Port Address Translation).The difference between a
*_StaticNAT_* and a *_PAT'd NAT_* is important. The Static NAT allows hosts from the *_OUTSIDE_* (i.e., the Internet) to establish a connection to the NAT'd host. Where as, with a *_PAT_*, the outsides hosts *_CANNOT_* establish connections (to a PAT'd host).
Quoted 6 lines
So the Internet border router needs to advertise the NAT IP (or the network containing the NAT IP) to the internet. But it also has to have a route that sends all traffic destined for that NAT IP (or Network) to the firewall's interface. This can be a static route.
Thank Kelly, I get all that, I'm having troubles with the single additional param to the ip add command, I presently have my public NAT side set in the external interface with ip add commands *lacking* the "secondary" parameter, thus they show as global additional address', what is the gain or rational for the secondary param to the ip add command syntax? The man page for ip does not give enough infor for me to determine the significance of the param to the command syntax. Hope I'm clear enough in tying to state this.
Basically what is the difference tween using the ip addcommand with and without the "secondary" param?
Thanks,
Ron DuFresne
- -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
admin & senior security consultant: sysinfo.com
http://sysinfo.com
Key fingerprint = 9401 4B13 B918 164C 647A E838 B2DF AFCC 94B0 6629
...We waste time looking for the perfect lover
instead of creating the perfect love.
-Tom Robbins <Still Life With Woodpecker>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFD4TRpst+vzJSwZikRAlugAKC9KdZJqUTZwyudOv6u3tZrgqS3IQCdFlOU QCs+Vbst9McTGLSYp5UhqDk=
=Qydo
-----END PGP SIGNATURE-----
Ah I see. The 'ip address' command has a few params. The 'ip addr' command will just apply the first or only ip address. 'ip addr add' adds another address. The secondary address.
#ip add help
Usage: ip addr {add|del} IFADDR dev STRING
ip addr {show|flush} [ dev STRING ] [ scope SCOPE-ID ]
[ to PREFIX ] [ FLAG-LIST ] [ label PATTERN ]
IFADDR := PREFIX | ADDR peer PREFIX
[ broadcast ADDR ] [ anycast ADDR ]
[ label STRING ] [ scope SCOPE-ID ]
SCOPE-ID := [ host | link | global | NUMBER ]
FLAG-LIST := [ FLAG-LIST ] FLAG
FLAG := [ permanent | dynamic | secondary | primary |
tentative | deprecated ]
Signature · 15 lines
kelly http://home1.gte.net/res0psau/index.html#Hang-Gliding-Stuff -- -- \ / \/ /\ / \ -- -- Quoting R. DuFresne <[email protected]>: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Wed, 1 Feb 2006, kelly wrote:
>I'm not sure if I'm addressing your question or >not, but I'll take a stab at what I *_think_* >you're refering to.
>
>The secondary IP address is a way of telling an >interface to accept (and send) packets on more >than one IP segment. It's the iproute2 utilities >way of doing the same thing as the ifconfig option >with the colon (sub-interface).
>
> i.e.
> eth0
> eth0:1
>
>For instance, if you have a private IP segment >(RFC 1918) between the firewall and the border >router (the border router connects your network to >the Internet in this case) -- i.e., 10.x.x.x --. >This private segment cannot be advertised to the >Internet.
>
>Therefore you can add a secondary IP address to >the firewall's ethernet interface. The secondary >IP address is a public IP that *_CAN_* be >advertised to the Internet. This same IP is the >IP you want to create a *_STATIC NAT_* to. Be >aware this is not a *_PAT_* (Port Address >Translation).
>
>The difference between a *_Static NAT_* and a >*_PAT'd NAT_* is important. The Static NAT allows >hosts from the *_OUTSIDE_* (i.e., the Internet) to >establish a connection to the NAT'd host. Where >as, with a *_PAT_*, the outsides hosts *_CANNOT_* >establish connections (to a PAT'd host). >
>So the Internet border router needs to advertise >the NAT IP (or the network containing the NAT IP) >to the internet. But it also has to have a route >that sends all traffic destined for that NAT IP >(or Network) to the firewall's interface. This >can be a static route.
Thank Kelly, I get all that, I'm having troubles with the single additional param to the ip add command, I presently have my public NAT side set in the external interface with ip add commands *lacking* the "secondary" parameter, thus they show as global additional address', what is the gain or rational for the secondary param to the ip add command syntax? The man page for ip does not give enough infor for me to determine the significance of the param to the command syntax. Hope I'm clear enough in tying to state this.
Basically what is the difference tween using the ip addcommand with and without the "secondary" param?
Thanks,
Ron DuFresne
- --
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
admin & senior security consultant: sysinfo.com
http://sysinfo.com
Key fingerprint = 9401 4B13 B918 164C 647A E838 B2DF AFCC 94B0 6629
...We waste time looking for the perfect lover instead of creating the perfect love.
-Tom Robbins <Still Life With Woodpecker>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFD4TRpst+vzJSwZikRAlugAKC9KdZJqUTZwyudOv6u3tZrgqS3IQCdFlOU QCs+Vbst9McTGLSYp5UhqDk=
=Qydo
-----END PGP SIGNATURE-----
A message that is not in the archive (sent off-list or not yet received): 20060201225341.GA3846@[email protected]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 5 lines · kelly
Ah I see. The 'ip address' command has a few params. The 'ip addr' command will just apply the first or only ip address. 'ip addr add' adds another address. The secondary address.
no it does not unless one spcifically applies the secondary param to the command, otherwise it applies the next and all proceeding addresses as globals, like this:
1: lo: <LOOPBACK,UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0d:56:11:11:11 brd ff:ff:ff:ff:ff:ff
inet 20.20.80.18/28 brd 20.20.80.31 scope global eth0
inet 20.20.80.19/32 scope global eth0
inet 20.20.80.20/32 scope global eth0
inet 20.20.80.21/32 scope global eth0
inet 20.20.80.22/32 scope global eth0
inet 20.20.80.23/32 scope global eth0
inet 20.20.80.24/32 scope global eth0
inet 20.20.80.25/32 scope global eth0
inet 20.20.80.26/32 scope global eth0
inet 20.20.80.27/32 scope global eth0
inet 20.20.80.28/32 scope global eth0
inet 20.20.80.29/32 scope global eth0
inet 20.20.80.30/32 scope global eth0
3: eth1: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0c:11:11:11:60 brd ff:ff:ff:ff:ff:ff
inet 192.168.80.19/28 brd 192.168.80.31 scope global eth1If secondary is appended to the command, then secondary is applied to the additional IP's and the ip add show output for that interfaces IP's. My questions is; beside being able to flush all addresses by flushing the main global address, what is the significance of the "secondary" attribute to the ip addr add command?
note the difference above to what is in your paper;
1: lo: mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
2: eth0: mtu 1500 qdisc pfifo_fast qlen 100
link/ether 00:10:5a:10:0d:37 brd ff:ff:ff:ff:ff:ff
inet 12.12.12.2/24 brd 12.12.12.255 scope global eth0
inet 12.12.12.12/24 scope global secondary eth0
3: eth1: mtu 1500 qdisc pfifo_fast qlen 100
link/ether 00:10:5a:10:0d:34 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.1/24 brd 192.168.1.255 scope global eth1In my output there is no "scope global secondary", never used that param on the commandline when setting up NAT, and yet mine works...
Quoted 14 lines
#ip add help
Usage: ip addr {add|del} IFADDR dev STRING
ip addr {show|flush} [ dev STRING ] [ scope SCOPE-ID ]
[ to PREFIX ] [ FLAG-LIST ] [ label PATTERN ]
IFADDR := PREFIX | ADDR peer PREFIX
[ broadcast ADDR ] [ anycast ADDR ]
[ label STRING ] [ scope SCOPE-ID ]
SCOPE-ID := [ host | link | global | NUMBER ]
FLAG-LIST := [ FLAG-LIST ] FLAG
FLAG := [ permanent | dynamic | secondary | primary |
tentative | deprecated ]
This is all undecipherable, and not explained at all in the man page, nor in the document that I did enjoy and wished I'd had found when fisrt setting up my 1:1 NAT setup. But as I keep asking what is the reall significance of the secondary attribute being added to the command as suggested but poorly explained in the documantation. Not adding that param and it all works fine, so what does that param addition really by me in a 1:1 NAT setup?
[SNIPPED old replies in this thread]
Thanks,
Ron DuFresne
- -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
admin & senior security consultant: sysinfo.com
http://sysinfo.com
Key fingerprint = 9401 4B13 B918 164C 647A E838 B2DF AFCC 94B0 6629
...We waste time looking for the perfect lover
instead of creating the perfect love.
-Tom Robbins <Still Life With Woodpecker>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFD4nNyst+vzJSwZikRAlb3AKCd63t2rSMmhbi8bWDwpaVyS2Zk1gCfcXlo /txM6QNbQjcVSPB1gjJ3UrQ=
=3amA
-----END PGP SIGNATURE-----
The syntax I used while testing doesn't seem to work on my new box. Maybe the 'global' entries will act the same way? Lab it up and let me know.
Maybe this verion of IPROUTE2 is different from what I used when I wrote that page.
#/sbin/ip addr add 12.12.12.12/24 dev eth0 secondary
Error: either "local" is duplicate, or "secondary" is a garbage.
#ip addr add help
Usage: ip addr {add|del} IFADDR dev STRING
ip addr {show|flush} [ dev STRING ] [ scope SCOPE-ID ]
[ to PREFIX ] [ FLAG-LIST ] [ label PATTERN ]
IFADDR := PREFIX | ADDR peer PREFIX
[ broadcast ADDR ] [ anycast ADDR ]
[ label STRING ] [ scope SCOPE-ID ]
SCOPE-ID := [ host | link | global | NUMBER ]
FLAG-LIST := [ FLAG-LIST ] FLAG
FLAG := [ permanent | dynamic | secondary | primary |
tentative | deprecated ]
Check out this doc. Look at section 5.2 on page
6. It talks about the 'secondary' addresses.
http://www.deepspace6.net/docs/iproute2tunnel-en.pdf
Signature · 15 lines
kelly http://home1.gte.net/res0psau/index.html#Hang-Gliding-Stuff -- -- \ / \/ /\ / \ -- -- Quoting R. DuFresne <[email protected]>: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Wed, 1 Feb 2006, kelly wrote:
>Ah I see. The 'ip address' command has a few >params. The 'ip addr' command will just apply the >first or only ip address. 'ip addr add' adds >another address. The secondary address. >
no it does not unless one spcifically applies the secondary param to the command, otherwise it applies the next and all proceeding addresses as globals, like this:
1: lo: <LOOPBACK,UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0d:56:11:11:11 brd ff:ff:ff:ff:ff:ff inet 20.20.80.18/28 brd 20.20.80.31 scope global eth0 inet 20.20.80.19/32 scope global eth0
inet 20.20.80.20/32 scope global eth0
inet 20.20.80.21/32 scope global eth0
inet 20.20.80.22/32 scope global eth0
inet 20.20.80.23/32 scope global eth0
inet 20.20.80.24/32 scope global eth0
inet 20.20.80.25/32 scope global eth0
inet 20.20.80.26/32 scope global eth0
inet 20.20.80.27/32 scope global eth0
inet 20.20.80.28/32 scope global eth0
inet 20.20.80.29/32 scope global eth0
inet 20.20.80.30/32 scope global eth0
3: eth1: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0c:11:11:11:60 brd ff:ff:ff:ff:ff:ff inet 192.168.80.19/28 brd 192.168.80.31 scope global eth1
If secondary is appended to the command, then secondary is applied to the additional IP's and the ip add show output for that interfaces IP's. My questions is; beside being able to flush all addresses by flushing the main global address, what is the significance of the "secondary" attribute to the ip addr add command?
note the difference above to what is in your paper;
1: lo: mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
2: eth0: mtu 1500 qdisc pfifo_fast qlen 100
link/ether 00:10:5a:10:0d:37 brd ff:ff:ff:ff:ff:ff inet 12.12.12.2/24 brd 12.12.12.255 scope global eth0 inet 12.12.12.12/24 scope global secondary eth0
3: eth1: mtu 1500 qdisc pfifo_fast qlen 100
link/ether 00:10:5a:10:0d:34 brd ff:ff:ff:ff:ff:ff inet 192.168.1.1/24 brd 192.168.1.255 scope global eth1
In my output there is no "scope global secondary", never used that param on the commandline when setting up NAT, and yet mine works...
>
>#ip add help
>Usage: ip addr {add|del} IFADDR dev STRING
> ip addr {show|flush} [ dev STRING ] [ scope SCOPE-ID ]
> [ to PREFIX ] [ FLAG-LIST ] [ label PATTERN ]
>IFADDR := PREFIX | ADDR peer PREFIX
> [ broadcast ADDR ] [ anycast ADDR ]
> [ label STRING ] [ scope SCOPE-ID ]
>SCOPE-ID := [ host | link | global | NUMBER ] >FLAG-LIST := [ FLAG-LIST ] FLAG
>FLAG := [ permanent | dynamic | secondary | primary |
> tentative | deprecated ]
>
>
This is all undecipherable, and not explained at all in the man page, nor in the document that I did enjoy and wished I'd had found when fisrt setting up my 1:1 NAT setup. But as I keep asking what is the reall significance of the secondary attribute being added to the command as suggested but poorly explained in the documantation. Not adding that param and it all works fine, so what does that param addition really by me in a 1:1 NAT setup?
[SNIPPED old replies in this thread]
Thanks,
Ron DuFresne
- --
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
admin & senior security consultant: sysinfo.com
http://sysinfo.com
Key fingerprint = 9401 4B13 B918 164C 647A E838 B2DF AFCC 94B0 6629
...We waste time looking for the perfect lover instead of creating the perfect love.
-Tom Robbins <Still Life With Woodpecker>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFD4nNyst+vzJSwZikRAlb3AKCd63t2rSMmhbi8bWDwpaVyS2Zk1gCfcXlo /txM6QNbQjcVSPB1gjJ3UrQ=
=3amA
-----END PGP SIGNATURE-----