How set metric on interfaces from ifcfg-ethx

Issues related to configuring your network

How set metric on interfaces from ifcfg-ethx

Postby mmmz » 2012/08/10 09:02:10

Hello,

a few words about my problem.

My server Centos 6.2 host virtual machines.

I have 2 nics on the same network.

The first one is eth0 and is used for base (physical) machine.
The second is a bridge (br0) and is used for virtual machines.

I would like to separate traffic network. br0 for virtual machine traffic and eth0 for physical machine

eth0 must be the gateway so it must have the lowest metric (ie 0) and eth2 (physical interface of br0) must have higher metric

Unfortunately eth0 is gateway but have metric it set to 1 and bridge interface is set to 0.

So my question: how force interface metric in ifcfg-ethx script ?

Here is scripts used to configure interfaces and bridge

Thanks by advance for help





ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=dhcp
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=eth0
HWADDR=xx:xx:xx:xx:xx:xx
PEERDNS=yes
PEERROUTES=yes
DEFROUTE=yes



ifcfg-br0

DEVICE=br0
TYPE=Bridge
BOOTPROTO=none
IPADDR=192.168.0.2
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
#STP=yes
DELAY=0
ONBOOT=yes
USERCTL=no
DEFROUTE=no




ifcfg-eth2
DEVICE=eth2
TYPE=Ethernet
BRIDGE=br0
HWADDR=yy:yy:yy:yy:yy:yy
ONBOOT=yes
USERCTL=no
mmmz
 
Posts: 9
Joined: 2009/07/26 16:38:00

Re: How set metric on interfaces from ifcfg-ethx

Postby TrevorH » 2012/08/10 11:15:33

Unless your eth0 interface has an IP address in the same subnet as br0 then it shouldn't make any difference.

Perhaps you could give a concrete example of what you see the problem to be? I suspect that you might just need to implement source based routing...
User avatar
TrevorH
Forum Moderator
 
Posts: 9168
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How set metric on interfaces from ifcfg-ethx

Postby mmmz » 2012/08/10 13:14:42

Thanks for your answer.

The two interfaces are in the same subnet indeed.

The gateway is eth0 with ip 192.168.0.x and metric 1
eth2 (br0) ip is 192.168.0.2 and metric is 0

so all packets sent to 192.168.0.0 subnet from physical machine are routed to eth2 even if eth0 is gateway.
mmmz
 
Posts: 9
Joined: 2009/07/26 16:38:00

Re: How set metric on interfaces from ifcfg-ethx

Postby hawkmage » 2012/08/11 00:01:12

I have not tried it but there is a parameter of METRIC that the ifup-eth script looks for and uses to set the metric of an interfaces default route.
hawkmage
 
Posts: 159
Joined: 2011/12/17 00:00:11

Re: How set metric on interfaces from ifcfg-ethx

Postby TrevorH » 2012/08/11 00:12:18

I'm not a networking guru but what you're trying to do just looks incorrect to me. I do not think you should have two interfaces on the same machine within the same subnet. What stops you from doing this properly and using different subnets for each interface? Or bonding them together if bandwidth is your consideration?
User avatar
TrevorH
Forum Moderator
 
Posts: 9168
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How set metric on interfaces from ifcfg-ethx

Postby mmmz » 2012/08/11 06:23:03

Hello and many thanks for your help


I try METRIC parameter without succes. I tried to use it in scritpts ifcfg-eth0, ifcfg-eth2, ifcfg-br0. It seems it ignore that parameter.

In general 2 nic on the same subnet is used for bonding and nic redundancy.
In my case, i would like to have stabilty on my physical machine. Because i have numerous change on VMs i prefere separate network interface for physical and virtual machine.

Metric can solve the problem but i unfortunetly i can set it.
mmmz
 
Posts: 9
Joined: 2009/07/26 16:38:00

How set metric on interfaces from ifcfg-ethx

Postby jlehtone » 2012/08/13 10:16:33

Why do you have an IP on the bridge? AFAIK, that is not necessary.

Are you using the NetworkManager or the network? The former is the default, but the latter generally "works better".
User avatar
jlehtone
 
Posts: 1431
Joined: 2007/12/11 08:17:33
Location: Finland

Re: How set metric on interfaces from ifcfg-ethx

Postby mmmz » 2012/08/23 07:50:29

Hello jlehtone and thanks for your help,

I am currently using a router with DNS, DHCP ... services but and the end, all that services will be hosted in a pfsense Virtual machine.
So some NIC will be gateway for LAN network (DMZ, HotSpot, LAN). I need to have fix addresses on those inferface.

I can have dedicaced NIC for a virtual machine. It seems to be posible with the last libvirt and kernel version but my CPU do not support virtualization technology for directed I/O (vt-d).
So i have to use bridges. But i want isolate NIC used for router from the rest of the base machine.
mmmz
 
Posts: 9
Joined: 2009/07/26 16:38:00

Re: How set metric on interfaces from ifcfg-ethx

Postby jlehtone » 2012/08/23 10:07:11

mmmz wrote:
I can have dedicaced NIC for a virtual machine. ... So i have to use bridges. But i want isolate NIC used for router from the rest of the base machine.

Yes.

The host has eth0, it has IP address, and the the host communicates via that interface.

Then there are eth2 and vnet* that are linked via br0. Traffic between physical network and the VM passes that pipe. There is absolutely nothing that the host needs to inject into that pipe and therefore there is no reason for the host to give an IP address to the bridge or its interfaces. Neat isolation.

When the host and the VM communicate with each other, the host will send out via eth0, the external switch will pass that to eth2 that gives packets to the bridge that in turn casts them to the VM. Replies reverse that path. From the viewpoint of the external switch the host and the VM are just two separate machines behind two separate ports.


Btw, you did not tell which service do you use on the host: NetworkManager or network.
User avatar
jlehtone
 
Posts: 1431
Joined: 2007/12/11 08:17:33
Location: Finland


Return to CentOS 6 - Networking Support

Who is online

Users browsing this forum: No registered users and 3 guests