Dual WAN set-up
Hi, folks.
Please bear with me. I may have asked something similar in the way-back, but am going to ask again, because I really need to get this set up, have absolutely no idea how, and am pertrified at the prospect:
I currently have an iptables/Netfilter firewall router configured thusly:
WAN
|(192.168.x.x) LAN -- fw -- DMZ (10.x.x.x)
OK, pretty basic. And, it has worked well for a long time.
Now, I need to add a second WAN (provided by a second provider). I need it to serve specific boxes in the DMZ, both inbound and outbound. Currently, all boxes in the DMZ are served by the single WAN connection. I'm not sure what other information I need to provide you, but I'm hoping you all can help with very specific instructions or a very detailed how-to so I can get this accomplished. And, of course, I need to get this done yesterday.
Many thanks.
Dimitri
Signature · 3 lines
This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.
Quoted 14 lines · Dimitri Yioulos
Hi, folks.
Please bear with me. I may have asked something similar in the way-back, but am going to ask again, because I really need to get this set up, have absolutely no idea how, and am pertrified at the prospect:
I currently have an iptables/Netfilter firewall router configured thusly:
WAN |(192.168.x.x) LAN -- fw -- DMZ (10.x.x.x)
Quoted 8 lines
OK, pretty basic. And, it has worked well for a long time.
Now, I need to add a second WAN (provided by a second provider). I need it to serve specific boxes in the DMZ, both inbound and outbound. Currently, all boxes in the DMZ are served by the single WAN connection. I'm not sure what other information I need to provide you, but I'm hoping you all can help with very specific instructions or a very detailed how-to
If you check the list archives there's been a few discussions on this recently (search for load balancing).
One way of doing it is marking each connection and balancing those, as described in this excellent web page:
Andy
Quoted 37 lines · Andrew Beverley
Quoted 16 lines · Dimitri Yioulos
Hi, folks.
Please bear with me. I may have asked something similar in the way-back, but am going to ask again, because I really need to get this set up, have absolutely no idea how, and am pertrified at the prospect:
I currently have an iptables/Netfilter firewall router configured thusly:
WAN
(192.168.x.x) LAN -- fw -- DMZ (10.x.x.x)
OK, pretty basic. And, it has worked well for a long time.
Quoted 7 lines
Now, I need to add a second WAN (provided by a second provider). I need it to serve specific boxes in the DMZ, both inbound and outbound. Currently, all boxes in the DMZ are served by the single WAN connection. I'm not sure what other information I need to provide you, but I'm hoping you all can help with very specific instructions or a very detailed how-to
If you check the list archives there's been a few discussions on this recently (search for load balancing).
One way of doing it is marking each connection and balancing those, as described in this excellent web page:
http://www.sysresccd.org/Sysresccd-Networking-EN-Iptables-and-n
etfilter-load-balancing-using-connmarkAndy
Quoted 6 lines
--
To unsubscribe from this list: send the line "unsubscribe netfilter" in the body of a message to [email protected]
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Thank, Andy. I'll give it a read. I'm not sure I'm after load balancing, though, but rather dedicating one WAN to a specific set of machines, if that's even possible. Also, I've seen how-to's on the NET, but all assume that you're starting fresh, and adding two WAN connections. I already have one in place, and working fine.
Dimitri
Signature · 3 lines
This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.
Quoted 4 lines · Dimitri Yioulos
I currently have an iptables/Netfilter firewall router configured thusly:
WAN |
Quoted 9 lines
(192.168.x.x) LAN -- fw -- DMZ (10.x.x.x)
OK, pretty basic. And, it has worked well for a long time. Now, I need to add a second WAN (provided by a second provider). I need it to serve specific boxes in the DMZ, both inbound and outbound. Currently, all boxes in the DMZ are served by the single WAN connection. I'm not sure what other information I need to provide you, but I'm hoping you all can help with very specific instructions or a very detailed how-to so I can get this accomplished. And, of course, I need to get this done yesterday.
Hi,
I am not highly experienced compared to most other posters here, but I'll try to help :)
Shouldn't your diagram indicate that the fw is connected to the WAN (not to the DMZ)? I will proceed under that assumption. If you have a netfilters firewall installed, I think all interfaces would go "through" it.
Adding a second (or more) uplink to a netfilters firewall is easy. I suggest the following:
1. You could follow the basic information explained here, to set up split access: http://lartc.org/howto/lartc.rpdb.multiple-links.html After reading this and understanding about using multiple routing tables to route traffic through different interfaces (uplinks), you can proceed.
2. You would set up a custom routing table for the special DMZ traffic. Use the info in the above link to do that. Suppose it is called "DMZSPECIAL". You will set up routing to the new DMZ interface using the MYDMZ table, something like this:
ip route add 10.x.x.x/8 dev ${DMZinterface} src ${wan} table DMZSPECIAL
ip route add default via ${gateway} dev ${interface} table DMZSPECIAL(You will also keep your regular routing table to your old interface. Also of course you keep your SNAT over your existing interface, only for LAN hosts of course.)
2. You might create a custom chain for the new interface, which is supposed to serve the special DMZ hosts. This is to mark packets for subsequent decision on routing:
iptables -t mangle -N CONNMARK1 iptables -t mangle -A CONNMARK1 -j MARK --set-mark 1 iptables -t mangle -A CONNMARK1 -j CONNMARK --save-mark iptables -t mangle -A CONNMARK1 -j ACCEPT
3. You would NEW mark all packets from the special DMZ hosts with fwmark 1, like this (repeat for each source IP or subnet to use the new interface):
iptables -t mangle -A PREROUTING -m state --state NEW -s 10.x.x.x -j CONNMARK1 etc.
4. You would restore the connection mark to the packet mark with a rule like this:
iptables -t mangle -A PREROUTING -i ${dmz_if} -m state --state ESTABLISHED,RELATED -j CONNMARK --restore-markThen add a policy routing rule, directing all traffic with the "1" mark to the new DMZ uplink:
ip rule add fwmark 1 table MYDMZ
That should do it. Post back if you have any trouble.
Signature · 1 line
Lloyd
Quoted 1 line · Lloyd Standish
Shouldn't your diagram indicate that the fw is connected to the WAN (not to the DMZ)? I will proceed under that assumption. If you have a netfilters firewall installed, I think all interfaces would go "through" it.
PS I meant to say, the WAN is connected to the fw, not directly to the DMZ.
Signature · 1 line
Lloyd
Quoted 1 line · Lloyd Standish
On Thu, 12 Jan 2012 15:51:18 -0600, Dimitri Yioulos
Quoted 76 lines · <[email protected]> wrote:
Quoted 4 lines
I currently have an iptables/Netfilter firewall router configured thusly:
WANQuoted 10 lines
(192.168.x.x) LAN -- fw -- DMZ (10.x.x.x)
OK, pretty basic. And, it has worked well for a long time. Now, I need to add a second WAN (provided by a second provider). I need it to serve specific boxes in the DMZ, both inbound and outbound. Currently, all boxes in the DMZ are served by the single WAN connection. I'm not sure what other information I need to provide you, but I'm hoping you all can help with very specific instructions or a very detailed how-to so I can get this accomplished. And, of course, I need to get this done yesterday.Hi,
I am not highly experienced compared to most other posters here, but I'll try to help :)
Shouldn't your diagram indicate that the fw is connected to the WAN (not to the DMZ)? I will proceed under that assumption. If you have a netfilters firewall installed, I think all interfaces would go "through" it.
Adding a second (or more) uplink to a netfilters firewall is easy. I suggest the following:
1. You could follow the basic information explained here, to set up split access:
http://lartc.org/howto/lartc.rpdb.multiple-links.html After reading this and understanding about using multiple routing tables to route traffic through different interfaces (uplinks), you can proceed.2. You would set up a custom routing table for the special DMZ traffic. Use the info in the above link to do that. Suppose it is called "DMZSPECIAL". You will set up routing to the new DMZ interface using the MYDMZ table, something like this:
ip route add 10.x.x.x/8 dev ${DMZinterface} src ${wan} tableDMZSPECIAL ip route add default via ${gateway} dev ${interface} table DMZSPECIAL
(You will also keep your regular routing table to your old interface. Also of course you keep your SNAT over your existing interface, only for LAN hosts of course.)
2. You might create a custom chain for the new interface, which is supposed to serve the special DMZ hosts. This is to mark packets for subsequent decision on routing:
iptables -t mangle -N CONNMARK1 iptables -t mangle -A CONNMARK1 -j MARK --set-mark 1 iptables -t mangle -A CONNMARK1 -j CONNMARK --save-mark iptables -t mangle -A CONNMARK1 -j ACCEPT3. You would NEW mark all packets from the special DMZ hosts with fwmark 1, like this (repeat for each source IP or subnet to use the new interface):
iptables -t mangle -A PREROUTING -m state --state NEW -s10.x.x.x -j CONNMARK1 etc.
4. You would restore the connection mark to the packet mark with a rule like this: iptables -t mangle -A PREROUTING -i ${dmz_if} -m state --state ESTABLISHED,RELATED -j CONNMARK --restore-mark
Then add a policy routing rule, directing all traffic with the "1" mark to the new DMZ uplink:
ip rule add fwmark 1 table MYDMZ
Quoted 9 lines
That should do it. Post back if you have any trouble. --
Lloyd
--
To unsubscribe from this list: send the line "unsubscribe netfilter" in the body of a message to [email protected]
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Lloyd,
Our fw/router routes traffic to both our LAN and our DMZ. That's how it was set up a long time ago and, again, it works very well. Given that, do your instructions (btw, did I say I'm grateful for your help) still work?
Dimitri
Signature · 3 lines
This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.
Quoted 1 line · Lloyd Standish
On Thu, 12 Jan 2012 17:08:08 -0600, Lloyd Standish
Quoted 5 lines · <[email protected]> wrote:
Quoted 4 lines
Shouldn't your diagram indicate that the fw is connected to the WAN (not to the DMZ)? I will proceed under that assumption. If you have a netfilters firewall installed, I think all interfaces would go "through" it.
Quoted 9 lines
PS I meant to say, the WAN is connected to the fw, not directly to the DMZ. --
Lloyd
--
To unsubscribe from this list: send the line "unsubscribe netfilter" in the body of a message to [email protected]
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Lloyd,
I should have read all your posts - correct, the WAN is connected to the fw. So is the DMZ.
Dimitri
Signature · 3 lines
This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.
Sorry, there are a couple of probably obvious errors in my post, aside from the bad numbering. This is because when I first wrote this, I gave the DMZ special hosts routing table the name "MYDMZ", but then changed it to "DMZSPECIAL", for clarity. The erred lines are corrected below:
Quoted 1 line · Lloyd Standish
2. You would set up a custom routing table for the special DMZ traffic. Use the info in the above link to do that. Suppose it is called "DMZSPECIAL". You will set up routing to the new DMZ interface using the MYDMZ table, something like this:
I meant to say above, "...using the DMZSPECIAL table, something like this:"
<snip>
Quoted 4 lines
Then add a policy routing rule, directing all traffic with the "1" mark to the new DMZ uplink:
ip rule add fwmark 1 table MYDMZ
This should of course be:
ip rule add fwmark 1 table DMZSPECIAL
Signature · 1 line
Lloyd
Quoted 14 lines · Dimitri Yioulos
Quoted 14 lines
Quoted 7 lines
Now, I need to add a second WAN (provided by a second provider). I need it to serve specific boxes in the DMZ, both inbound and outbound. Currently, all boxes in the DMZ are served by the single WAN connection. I'm not sure what other information I need to provide you, but I'm hoping you all can help with very specific instructions or a very detailed how-to
If you check the list archives there's been a few discussions on this recently (search for load balancing).
One way of doing it is marking each connection and balancing those, as described in this excellent web page:
Quoted 7 lines
Quoted 3 lines
http://www.sysresccd.org/Sysresccd-Networking-EN-Iptables-and-n
etfilter-load-balancing-using-connmarkThank, Andy. I'll give it a read. I'm not sure I'm after load balancing, though, but rather dedicating one WAN to a specific set of machines, if that's even possible.
Ah, sorry, you did say that, I just misread your email (and original diagram of course!)
Quoted 4 lines
Also, I've seen
how-to's on the NET, but all assume that you're starting fresh, and adding two WAN connections. I already have one in place, and working fine.
Well that should be pretty easy to be honest. What Lloyd wrote looks pretty spot-on, and is the way that I would approach this problem.
Andy
Thanks for the comprehensive answer Lloyd. A couple of minor points:
Quoted 8 lines
2. You would set up a custom routing table for the special DMZ traffic. Use the info in the above link to do that. Suppose it is called
"DMZSPECIAL". You will set up routing to the new DMZ interface using the MYDMZ table, something like this:ip route add 10.x.x.x/8 dev ${DMZinterface} src ${wan} table DMZSPECIAL ip route add default via ${gateway} dev ${interface} table DMZSPECIAL
[...]
Quoted 3 lines
3. You would NEW mark all packets from the special DMZ hosts with fwmark 1, like this (repeat for each source IP or subnet to use the new interface):
Using marks is one way to do this, and provides plenty of flexibility. However, if all the traffic is coming from the same IP address / interface, then you should be able to use straight iproute2 rules to match those aspects, without even touching iptables (see ip rule).
Quoted 3 lines
iptables -t mangle -A PREROUTING -m state --state NEW-s 10.x.x.x -j CONNMARK1
Also, if you do decide to use netfilter marks (which is certainly no bad thing IMHO), then you probably don't need to mark connections and then restore them. Instead just mark a packet straight away:
iptables -t mangle -A PREROUTING -s 10.x.x.x -j MARK --set-mark 1
Andy
Quoted 1 line · Andrew Beverley
Thanks for the comprehensive answer Lloyd. A couple of minor
points:
Quoted 36 lines
Quoted 9 lines
2. You would set up a custom routing table for the special DMZ traffic. Use the info in the above link to do that. Suppose it is called "DMZSPECIAL". You will set up routing to the new DMZ interface using the MYDMZ table, something like this:
ip route add 10.x.x.x/8 dev ${DMZinterface} src ${wan} tableDMZSPECIAL ip route add default via ${gateway} dev ${interface} table DMZSPECIAL
[...]
Quoted 3 lines
3. You would NEW mark all packets from the special DMZ hosts with fwmark 1, like this (repeat for each source IP or subnet to use the new interface):
Using marks is one way to do this, and provides plenty of flexibility. However, if all the traffic is coming from the same IP address / interface, then you should be able to use straight iproute2 rules to match those aspects, without even touching iptables (see ip rule).
Quoted 2 lines
iptables -t mangle -A PREROUTING -m state --state NEW-s 10.x.x.x -j CONNMARK1
Also, if you do decide to use netfilter marks (which is certainly no bad thing IMHO), then you probably don't need to mark connections and then restore them. Instead just mark a packet straight away:
iptables -t mangle -A PREROUTING -s 10.x.x.x -j MARK --set-mark 1
Andy
Quoted 6 lines
--
To unsubscribe from this list: send the line "unsubscribe netfilter" in the body of a message to [email protected]
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Thanks to you both. I'll go over your suggestions, and try to implement this asap. Please stand by as I may need additional hand-holding :-) .
Dimitri
Signature · 3 lines
This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.
Quoted 8 lines · Andrew Beverley
Using marks is one way to do this, and provides plenty of flexibility. However, if all the traffic is coming from the same IP address / interface, then you should be able to use straight iproute2 rules to match those aspects, without even touching iptables (see ip rule).
Quoted 3 lines
iptables -t mangle -A PREROUTING -m state --state NEW-s 10.x.x.x -j CONNMARK1
That's a good point. In my own firewall, at one point I wanted to avoid load-balancing for certain hosts (i.e., always route through a given interface for a certain source IP), and I was unable to use "ip rule" with no packet marking. However, I think this is because all the hosts were internal LAN hosts using SNAT, and the NAT is done before the packet hits "ip rule." Therefore "ip rule" could not match on the source IP. But in Dimitri's case, since there is no NAT for the DMZ hosts, this should work fine, and is simpler. The only reason to mark packets would be to allow the possibility of later routing some of the LAN hosts through the second interface.
Quoted 4 lines
Also, if you do decide to use netfilter marks (which is certainly no bad thing IMHO), then you probably don't need to mark connections and then restore them. Instead just mark a packet straight away:
iptables -t mangle -A PREROUTING -s 10.x.x.x -j MARK --set-mark 1
Another very good point for Dimitri, Andy, which should give better efficiency. Connection marking is only necessary for load-balancing. I guess I am in a "load-balancing" mindset.
Signature · 1 line
Lloyd
Quoted 1 line · Lloyd Standish
On Fri, 13 Jan 2012 01:25:45 -0600, Andrew Beverley
Quoted 31 lines · <[email protected]> wrote:
Quoted 8 lines
Using marks is one way to do this, and provides plenty of flexibility. However, if all the traffic is coming from the same IP address / interface, then you should be able to use straight iproute2 rules to match those aspects, without even touching iptables (see ip rule).
Quoted 2 lines
iptables -t mangle -A PREROUTING -m state --state NEW-s 10.x.x.x -j CONNMARK1
That's a good point. In my own firewall, at one point I wanted to avoid load-balancing for certain hosts (i.e., always route through a given interface for a certain source IP), and I was unable to use "ip rule" with no packet marking. However, I think this is because all the hosts were internal LAN hosts using SNAT, and the NAT is done before the packet hits "ip rule." Therefore "ip rule" could not match on the source IP. But in Dimitri's case, since there is no NAT for the DMZ hosts, this should work fine, and is simpler. The only reason to mark packets would be to allow the possibility of later routing some of the LAN hosts through the second interface.
Quoted 5 lines
Also, if you do decide to use netfilter marks (which is certainly no bad thing IMHO), then you probably don't need to mark connections and then restore them. Instead just mark a packet straight away: iptables -t mangle -A PREROUTING -s 10.x.x.x -j MARK --set-mark 1
Another very good point for Dimitri, Andy, which should give better efficiency. Connection marking is only necessary for load-balancing. I guess I am in a "load-balancing" mindset.
Quoted 8 lines
--
Lloyd
--
To unsubscribe from this list: send the line "unsubscribe netfilter" in the body of a message to [email protected]
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Lloyd,
Not to throw a proverbial wrench in the works, but in my case there is NAT for the DMZ hosts.
I have three NICs currently active on the fw (more are available):
eth0 - WAN, eth1 - LAN, eth2 - DMZ. In addition, eth0 has several aliases for the external addresses of the DMZ boxes. Then, NAT to internal addresses (10.x.x.x).
Hope I'm not muddying the waters but, rather, providing all of the info that you need to so kindly help me.
Dimitri
Signature · 3 lines
This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.
Quoted 55 lines · you
Quoted 1 line · Lloyd Standish
On Fri, 13 Jan 2012 01:25:45 -0600, Andrew Beverley
Quoted 32 lines · <[email protected]> wrote:
Quoted 8 lines
Using marks is one way to do this, and provides plenty of flexibility. However, if all the traffic is coming from the same IP address / interface, then you should be able to use straight iproute2 rules to match those aspects, without even touching iptables (see ip rule).
Quoted 2 lines
iptables -t mangle -A PREROUTING -m state --state NEW-s 10.x.x.x -j CONNMARK1
That's a good point. In my own firewall, at one point I wanted to avoid load-balancing for certain hosts (i.e., always route through a given interface for a certain source IP), and I was unable to use "ip rule" with no packet marking. However, I think this is because all the hosts were internal LAN hosts using SNAT, and the NAT is done before the packet hits "ip rule." Therefore "ip rule" could not match on the source IP. But in Dimitri's case, since there is no NAT for the DMZ hosts, this should work fine, and is simpler.
The only reason to mark packets would be to allow the
possibility of later routing some of the LAN hosts through the second interface.Quoted 5 lines
Also, if you do decide to use netfilter marks (which is certainly no bad thing IMHO), then you probably don't need to mark connections and then restore them. Instead just mark a packet straight away: iptables -t mangle -A PREROUTING -s 10.x.x.x -j MARK --set-mark 1
Another very good point for Dimitri, Andy, which should give better efficiency. Connection marking is only necessary for load-balancing. I guess I am in a "load-balancing" mindset.
Quoted 8 lines
--
Lloyd
--
To unsubscribe from this list: send the line "unsubscribe netfilter" in the body of a message to [email protected]
More majordomo info at
http://vger.kernel.org/majordomo-info.htmlLloyd,
Not to throw a proverbial wrench in the works, but in my case there is NAT for the DMZ hosts.
I have three NICs currently active on the fw (more are available): eth0 - WAN, eth1 - LAN, eth2 - DMZ. In addition, eth0 has several aliases for the external addresses of the DMZ boxes. Then, NAT to internal addresses (10.x.x.x).
Quoted 4 lines
Hope I'm not muddying the waters but, rather, providing all of the info that you need to so kindly help me.
Dimitri
Er, sorry, seems like I don't even remember my own network scheme. internal LAN addresses are 192.168.100.0/22, and internal DMZ addresses are 192.168.1.0/24. (The 10.x.x.x addresses are used by our VPN.)
Dimitri
Signature · 3 lines
This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.
Quoted 2 lines · Dimitri Yioulos
Not to throw a proverbial wrench in the works, but in my case there is NAT for the DMZ hosts.
I don't have time to elaborate now, but I think you will have to use connection marking (as in my previous post). I'll reply more in depth later.
Regards
Signature · 1 line
Lloyd
Quoted 1 line · Lloyd Standish
On Fri, 13 Jan 2012 09:17:21 -0600, Dimitri Yioulos
Quoted 10 lines · <[email protected]> wrote:
Quoted 2 lines
Not to throw a proverbial wrench in the works, but in my case there is NAT for the DMZ hosts.
I don't have time to elaborate now, but I think you will have to use connection marking (as in my previous post). I'll reply more in depth later.
Regards
--
Lloyd
Lloyd,
Excellent, and very appreciated (Andy's help, too).
Dimitri
Signature · 3 lines
This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.
Quoted 4 lines · Dimitri Yioulos
Er, sorry, seems like I don't even remember my own network scheme. internal LAN addresses are 192.168.100.0/22, and internal DMZ addresses are 192.168.1.0/24. (The 10.x.x.x addresses are used by our VPN.)
Again, I think you will have to use connection marking/mark restore as I detailed in a previous post. I don't believe that "ip rule add from x.x.x.x fwmark 1" will work when nat is used. Andy or another of the experts here may have comments on this. Otherwise, I think you can go ahead and try implementing your multi-uplink firewall based on the advice Andy and I have offered.
Signature · 1 line
Lloyd
Quoted 2 lines · Dimitri Yioulos
Before I commit this new set-up, I'd like to post the ste-by-step instructions I wrote up for your kind review:
I don't quite understand your network configuration, but the ideas we provided on split-access to uplinks should adaptable to any situation.
Quoted 5 lines
Under this set-up, don't I need to add POSTROUTING AND FORWARDING rules? Sorry for my stupidity, but I set the original up a long time ago, and certainly don't know all there is to know. Your continued patience and support are greatly appreciated.
The PREROUTING chain of the mangle table will handle the marking of new connection packets as well as recovery of the connection mark to the packet mark. There should be no other iptables stuff required to mark the packets, and "ip rule add fwmark..." will handle sending the marked packets to the right routing table.
I think you are doing SNAT, which uses POSTROUTING chain. You you will want to keep that.
Others here are much more knowledgeable and may have more comments.
Signature · 1 line
Lloyd