configure primary/secondary nic

Hi,I have a server with 2 network cards, they are configured with IPs. How can I set one of them as a primary and the other as a scondary NIC?Thanks.
[170 byte] By [bfarraj] at [2007-11-26 8:21:54]
# 1
Hi,What do you mean by this ?If you want 1 interface to be the primary and another one as a standby i'd say you might want to go for something like IPMP (IP Multipathing) so you can configure 1 interface as a standby in case the other 1 fails.Nico
NicoB at 2007-7-6 21:29:11 > top of Java-index,General,Sys Admin Best Practices...
# 2
Nico,I know how to configure IPMP. What I have is 2 interfaces connected to 2 different networks, and when I use ping or telnet, I want to connect to devices on the first network card by default without having to specify using this interface specifically.bfarraj
bfarraj at 2007-7-6 21:29:11 > top of Java-index,General,Sys Admin Best Practices...
# 3
Hi,So what you want is something like a preferred route ?Nico
NicoB at 2007-7-6 21:29:11 > top of Java-index,General,Sys Admin Best Practices...
# 4
Nico,I guess this is it.bfarraj
bfarraj at 2007-7-6 21:29:11 > top of Java-index,General,Sys Admin Best Practices...
# 5

Let's consider this for a moment --

hostA --> NICA (subnet A), NICB (subnet B)

hostB --> NICA(suibnet A), NICB (subnet B)

you want hostA(NICA) to connect to hostB(NICB) (when trying to connect to hostB) even though hostA(NICB) is in the same subnet as hostB(NICB)?

Or have I misunderstood your requirement?

implicate_order at 2007-7-6 21:29:11 > top of Java-index,General,Sys Admin Best Practices...
# 6
*cough* /etc/defaultrouter *cough*The TS clearly states that both NICs are on two separate networks.
Cailin_Coilleach at 2007-7-6 21:29:11 > top of Java-index,General,Sys Admin Best Practices...
# 7
heheThe problem doesn't seem as simple as that (or mayhaps it's the convolutions in my CPU that's making me think that way).
implicate_order at 2007-7-6 21:29:11 > top of Java-index,General,Sys Admin Best Practices...
# 8

> Nico,

>

> I know how to configure IPMP. What I have is 2

> interfaces connected to 2 different networks, and

> when I use ping or telnet, I want to connect to

> devices on the first network card by default without

> having to specify using this interface specifically.

what OS? Solaris 10 has additional commands that allow you to specify a particular address as the default for outbound connections (the question doesn't really make sense for inbound).

I don't know any real easy way to do so in previous versions.

--

Darren

Darren_Dunham at 2007-7-6 21:29:11 > top of Java-index,General,Sys Admin Best Practices...
# 9

> I want to connect to devices on the first network card by default

> without having to specify using this interface specifically.

How is this not a default route?

The only exception being the fact that you simply cannot force the OS to take the long way around of the system you're trying to reach is connected to the subnet of the second interface.

For example:

You're on host A and you're trying to reach host B...

[ host B ] router 3 router 2 router 1 subnet 1 NIC 1 [ host A ] NIC2 subnet 2 [ host B ]

I don't think there's -any- way of telling the OS to take the route through NIC1 to reach hosts in subnet 2, without actively disabling the route for NIC2.

Now I'm actually getting curious why you would want to do such a thing?

Message was edited by:

Cailin_Coilleach

Cailin_Coilleach at 2007-7-6 21:29:11 > top of Java-index,General,Sys Admin Best Practices...
# 10

> > I want to connect to devices on the first network

> card by default

> > without having to specify using this interface

> specifically.

> How is this not a default route?

I read his question as asking about what address/interface that outbound TCP connections will use by default. Of course I may be misinterpreting.

--

Darren

Darren_Dunham at 2007-7-6 21:29:11 > top of Java-index,General,Sys Admin Best Practices...
# 11
Hi,I want hostA (Nic B) to connect to host B(NicB). How does Solaris know that he should use NIC B to reach HostB (NIC B) if his default or primary NIC is NIC A?More than this, how does solaris know which is his default or primary interface?
bfarraj at 2007-7-6 21:29:11 > top of Java-index,General,Sys Admin Best Practices...
# 12
The OS is Solaris 9, 9/05.What are the commands in Solaris 10?Thanks.
bfarraj at 2007-7-6 21:29:11 > top of Java-index,General,Sys Admin Best Practices...
# 13

You are not misinterpreting, this is what I want.

> > > I want to connect to devices on the first

> network

> > card by default

> > > without having to specify using this interface

> > specifically.

> > How is this not a default route?

>

> I read his question as asking about what

> address/interface that outbound TCP connections will

> use by default. Of course I may be misinterpreting.

>

> --

> Darren

bfarraj at 2007-7-6 21:29:11 > top of Java-index,General,Sys Admin Best Practices...
# 14

> How does Solaris know that he should use NIC B to reach HostB (NIC B)

> if his default or primary NIC is NIC A?

Basic routing? Solaris will figure out the shortest way to a destination. If the shortest route is through one of its other interfaces which -doesn't- lead through the default gateway, then it will still take the shortest route.

> More than this, how does solaris know which is his default or primary interface?

I am not sure if there is such a distinction within Solaris.

Cailin_Coilleach at 2007-7-6 21:29:11 > top of Java-index,General,Sys Admin Best Practices...
# 15

> I want hostA (Nic B) to connect to host B(NicB). How

> does Solaris know that he should use NIC B to reach

> HostB (NIC B) if his default or primary NIC is NIC

> A?

Can you provide a configuration of your host? (ifconfig -a and netstat -nr output?)

> More than this, how does solaris know which is his

> default or primary interface?

Generally there's no such thing. Placing 2 interfaces on the same subnet without using IPMP isn't supported. So if the interfaces are on different subnets, then the routing table usually distinguishes between each. If you use IPMP, then both interfaces are used for aggregate connections.

--

Darren

Darren_Dunhama at 2007-7-21 15:12:10 > top of Java-index,General,Sys Admin Best Practices...
# 16

[[[Generally there's no such thing. Placing 2 interfaces on the same subnet without using IPMP isn't supported]]]

Why not? I must admit I haven't tried it (never had to), but still..I'm curious.

It's interesting, that there isn't any source affinity built into the Datalink layer in Solaris/Sun drivers. Diagnostic commands can be told to use a particular NIC to run the diagnostics (like ping and traceroute). I have a feeling he's (original poster) is asking it for Load balancing needs -- in which case there would have to be special/specialized software to do the needful...I think.

implicate_ordera at 2007-7-21 15:12:10 > top of Java-index,General,Sys Admin Best Practices...
# 17
Now I thought I was going mad, but I wasn't... The TS has stated on more than one occasion that his NICs are in separate subnets...> What I have is 2 interfaces connected to 2 different networks,
Cailin_Coilleacha at 2007-7-21 15:12:10 > top of Java-index,General,Sys Admin Best Practices...
# 18

[[[t's interesting, that there isn't any source affinity built into the Datalink layer in Solaris/Sun drivers. Diagnostic commands can be told to use a particular NIC to run the diagnostics (like ping and traceroute).]]]

To add to this -- by definition, IP datagrams should be tied to physical MAC (unless they've gone and changed the RFCs on me again :)) -- so source affinity should be built in (unless local-mac-address? is set to false)

implicate_ordera at 2007-7-21 15:12:10 > top of Java-index,General,Sys Admin Best Practices...
# 19

> [[[Generally there's no such thing. Placing 2

> interfaces on the same subnet without using IPMP

> isn't supported]]]

> Why not? I must admit I haven't tried it (never had

> to), but still..I'm curious.

Because in that configuration the routing table will pick one of the interfaces as the route to the subnet. So you have no redundancy.

If the link goes down, neither the IP binding nor the routing table will see that. It still tries to push the data out the interface and you lose your connectivity.

So you can set things up that way, but it probably won't do what you expect.

IPMP monitors traffic on the link, so it's the supported way to do this.

> It's interesting, that there isn't any source

> affinity built into the Datalink layer in Solaris/Sun

> drivers. Diagnostic commands can be told to use a

> particular NIC to run the diagnostics (like ping and

> traceroute). I have a feeling he's (original poster)

> is asking it for Load balancing needs -- in which

> case there would have to be special/specialized

> software to do the needful...I think.

IPMP will do a type of load balancing on outbound data. In addition, it monitors connectivity and can handle failures of a link.

--

Darren

Darren_Dunhama at 2007-7-21 15:12:10 > top of Java-index,General,Sys Admin Best Practices...
# 20

> To add to this -- by definition, IP datagrams should

> be tied to physical MAC (unless they've gone and

> changed the RFCs on me again :)) -- so source

> affinity should be built in (unless

> local-mac-address? is set to false)

I don't follow. Why are IP datagrams tied to a physical MAC?

On my machine, I have subnet A and subnet B attached to separate interfaces. If I send a packet with source IP: S and destination IP A.x, then I expect it to go out the interface on subnet A and use that MAC for source ether.

If I send a packet with the same source IP, but with destination IP B.x, then I expect it to use the other interface and have a separate mac address for the source.

Did I misunderstand what you meant?

--

Darren

Darren_Dunhama at 2007-7-21 15:12:10 > top of Java-index,General,Sys Admin Best Practices...
# 21

[[[I don't follow. Why are IP datagrams tied to a physical MAC?]]]

Corrections -- the mac address get's put in later (at the datalink layer). The ARP/RARP protocol helps resolve IP to MAC (and vice versa).

And I see what you mean about two interfaces being on the same vlan/subnet not supported. It would probably be detrimental (more than anything else) to route add the second IP/NIC into the routing table.

Message was edited by:

implicate_order

implicate_ordera at 2007-7-21 15:12:10 > top of Java-index,General,Sys Admin Best Practices...
# 22

> And I see what you mean about two interfaces being on

> the same vlan/subnet not supported. It would probably

> be detrimental (more than anything else) to route add

> the second IP/NIC into the routing table.

They are both in the routing table (added when the interface is brought UP by ifconfig). It's just that they have identical weights (both are directly connected), so a packet has no reason to prefer one over the other.

One of them will be selected for all traffic rather than both used in some sort of round-robin.

--

Darren

Darren_Dunhama at 2007-7-21 15:12:10 > top of Java-index,General,Sys Admin Best Practices...
# 23
Please specify if the tow nic cards are both INTERNET connection or if NIC-A is INTRANETand NIC-B is INTERNET. I want to know if both cards are using public address.Regards,
jupiter55a at 2007-7-21 15:12:10 > top of Java-index,General,Sys Admin Best Practices...
# 24

Solaris uses a Routing Table. To check your setup type:

# netstat -nr

Routing Table: IPv4

DestinationGatewayFlags RefUseInterface

-- -- -- --

192.168.4.0 172.31.254.1 UG170

172.31.254.0 172.31.254.10U 1393 ce0

224.0.0.0172.31.254.10U 10 ce0

default 172.31.254.2 UG11144

127.0.0.1127.0.0.1UH501916430 lo0

Your default route will be listed under the Destination column, in this case 'default'. So the default route will use the Gateway 172.31.254.2 in this example. You will also notice there is another defined route to another network. The first entry defines a network. So to get to anything on the 192.168.4.xxx network, Solaris will use the gateway 172.31.254.1.

This also applies to other NICs on the system. You will need to define a route for them so Solaris knows which interface to use for a given network or node.

To setup these routes you use the "route add" command. Ex:

route add -net 192.168.4 172.31.254.1

route add default 172.31.254.2

However, prior to running the route add command, you should check and see how your installation setup the routes by using the "netstat" command.

Hope this helps.

olgoat69a at 2007-7-21 15:12:10 > top of Java-index,General,Sys Admin Best Practices...