Networking Forums

Networking Forums > Computer Networking > Linux Networking > 2 NICs, 1 server

Reply
Thread Tools Display Modes

2 NICs, 1 server

 
 
Kradorex Xeron
Guest
Posts: n/a

 
      12-20-2007, 07:22 AM
Hi,

I have a situation where I have one NIC connected to a switch on a server,
and two internet connections on the switch, before I continue, I don't need
channel bonding and I don't need load balencing because that's not what I
need nor want.

Here's my physical configuration (Best viewed in monospace font):

<CONNECTION 1>---[ISP 1]
|
[NAT]
|
<SERVER>-------[SWITCH] (note: Both NAT routers are on the same subnet)
|
[NAT]
|
<CONNECTION 2>---[ISP 2]

The server is only able to route out one connection or the other at the
moment. Basically what I want is for the server to be able to route out the
connection it came in on. I wish for this to have the least impacting
solution on the system possible.

Thank you,

--
--Krad Xeron
 
Reply With Quote
 
 
 
 
Pascal Hambourg
Guest
Posts: n/a

 
      12-20-2007, 12:18 PM
Hello,

Kradorex Xeron a écrit :
>
> Here's my physical configuration (Best viewed in monospace font):
>
> <CONNECTION 1>---[ISP 1]
> |
> [NAT]
> |
> <SERVER>-------[SWITCH] (note: Both NAT routers are on the same subnet)
> |
> [NAT]
> |
> <CONNECTION 2>---[ISP 2]
>
> The server is only able to route out one connection or the other at the
> moment. Basically what I want is for the server to be able to route out the
> connection it came in on.


The server needs to use advanced routing. The general idea is to create
an alternate routing table for outgoing packets which must be routed
through the non-default router.

I can suggest three approaches. The first one is to add an alternate IP
address to the server in the same subnet, configure the non default
router to forward incoming connections to the alternate IP address, and
create a routing rule on the server saying to use the alternate routing
table to route outgoing packets with the alternate source address.

Guidelines :
# add alternate address to the LAN interface
ip addr add <alternate_address> dev <interface>

# add route to the LAN hosts in the alternate routing table
ip route add <local_net>/<mask|length> dev <interface> table 100

# add default route in the alternate routing table
ip route add default via <non_default_router_address> table 100

# create a routing rule based on source address
ip rule add from <alternate_address> lookup 100


The second approach is to mark the incoming connections forwarded by the
non-default router with iptables and create a routing rule saying to use
the alternate routing table to route outgoing packets with the mark. A
difficulty is to detect that a connection was forwarded by the
non-default router. Its IP address does not appear in the forwarded
packets so it cannot be used. Its MAC address can be used instead. IP
header fields such as TOS may be used too.

Guidelines :
# add default route in the alternate routing table
ip route add default via <non_default_router_address> table 100

# create a routing rule based on iptables mark
ip rule add fwmark 0x1 lookup 100

# add mark to connections from the non-default router MAC address
iptables -t mangle -A PREROUTING -m state --state NEW,RELATED \
-m mac --mac-source <non_default_router_mac> -j CONNMARK --set-mark 0x1

# copy the connection mark into outgoing packets
iptables -t mangle -A OUTPUT -j CONNMARK --restore-mark


The third approach is to mark outgoing packets with source ports
corresponding to the hosted services, and create a routing rule saying
to use the alternate routing table to route outgoing packets with the
mark. Note that this approach may not be applicable in all cases.

Guidelines :
# add route to the LAN hosts in the alternate routing table
ip route add <local_net>/<mask|length> dev <interface> table 100

# add default route in the alternate routing table
ip route add default via <non_default_router_address> table 100

# create a routing rule based on iptables mark
ip rule add fwmark 0x1 lookup 100

# mark outgoing packets with specific protocols and source ports
# destination addresses in the local network are excluded
iptables -t mangle -A OUTPUT -d ! <local_net>/<mask|length> \
-p <protocol> -m multiport --sports <ports> -j MARK --set-mark 0x1
 
Reply With Quote
 
buck
Guest
Posts: n/a

 
      12-20-2007, 06:12 PM
On Thu, 20 Dec 2007 03:22:26 -0500, Kradorex Xeron <(E-Mail Removed)>
wrote:

>Hi,
>
>I have a situation where I have one NIC connected to a switch on a server,
>and two internet connections on the switch, before I continue, I don't need
>channel bonding and I don't need load balencing because that's not what I
>need nor want.
>
>Here's my physical configuration (Best viewed in monospace font):
>
> <CONNECTION 1>---[ISP 1]
> |
> [NAT]
> |
><SERVER>-------[SWITCH] (note: Both NAT routers are on the same subnet)
> |
> [NAT]
> |
> <CONNECTION 2>---[ISP 2]
>
>The server is only able to route out one connection or the other at the
>moment. Basically what I want is for the server to be able to route out the
>connection it came in on. I wish for this to have the least impacting
>solution on the system possible.
>
>Thank you,


I suspect that you would have far better results if you eliminated the
two NATs so that the two external IPs are present on the switch.

If Pascal's three approaches do not accomplish what you want, I urge
you to post this message - plus details about SERVER - to the LARTC
mailing list.
--
buck

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
2 NICs, 1 server Kradorex Xeron Linux Networking 12 12-28-2007 09:52 PM
TWO NICs on win 2003 server(10.0.0.0/24 - 192.168.5.0/24) test_anywhere2@yahoo.com Windows Networking 2 12-29-2005 03:03 PM
Server with 3 NICs Windows Networking 10 07-03-2004 02:24 AM
one server, 2 nics Hernan s Windows Networking 5 05-25-2004 02:49 PM
Cluster server with 3 Nics =?Utf-8?B?TWlrZQ==?= Windows Networking 0 12-17-2003 02:41 PM



1 2 3 4 5 6 7 8 9 10 11