Using NetworkManager, I am trying to setup multiple interfaces on different VLANs; the primary interface, em1, is used on a development VLAN; the secondary interface is on a dedicated iSCSI VLAN.
I am using kernel arguments to launch the host from an iSCSI disk:
GRUB_CMDLINE_LINUX="netroot=iscsi:@172.16.250.250::3260:em2:::iqn.2000-01.com.example.san:disk rd.iscsi.initiator=iqn.2000-01.com.example.node:root rd.lvm.lv=centos/root
To prevent dracut from overriding changes to network config files, I added an override to the dracut config file, the rebuilt:
echo 'omit_dracutmodules+="ifcfg"' >> /etc/dracut.conf
dracut -f
grub2-mkconfig -o /boot/grub2/grub.cfg
After a reboot, I used nmtui
to configure the adapters, this built config files with these parameters:
DEVICE= em1 em2
ONBOOT= yes yes
BOOTPROTO= dhcp dhcp
DEFROUTE= yes no
PEERDNS= no
PEERROUTES= no
I need em1 to be the primary / default interface, em2 is to dedicated to iSCSI; the issue however is that em2 is still adding default routes. After a reboot:
$ ip route show
default via 172.16.250.1 dev em2 <-- WRONG
default via 172.16.100.1 dev em1 proto dhcp metric 100
172.16.100.0/24 dev em1 proto kernel scope link src 172.16.100.100
172.16.100.0/24 dev em1 proto kernel scope link src 172.16.100.100 metric 100
172.16.250.0/24 dev em2 proto kernel scope link src 172.16.250.100
172.16.250.0/24 dev em2 proto kernel scope link src 172.16.250.100 metric 101
There are no route- config files.
Here are some related nmcli options:
$ nmcli c show $if | grep ipv4
em1 em2
ipv4.routes -- --
ipv4.route-metric -1 -1
ipv4.route-table 0 (unspec) 0 (unspec)
ipv4.routing-rules -- --
ipv4.ignore-auto-routes no yes
ipv4.ignore-auto-dns no yes
ipv4.never-default no yes
I am not certain what is generating this extra route, how can I check what is creating it and prevent it?
It looks like you're getting your IP address via DHCPv4. In this case, by default, the default gateway will be set based on whatever the DHCP server sends. If you use DHCP on two distinct interfaces, as you have done here, you may get two gateways - which in this case conflict.
You can tell NetworkManager to ignore one of the gateways by configuring the connection explicitly as shown here.
For example (substitute your connection's actual name for
em2
):This will cause the default gateway from the DHCP server to be ignored. The equivalent GUI option is: "Use this connection only for resources on its network".
In addition, I suspect your mystery extra routes are coming from dracut when it brings up the network interface (with dhcp). You should consider manually configuring the
em2
interface on the kernel command line rather than using DHCP.Finally you should have a long chat with your network people about why there is a default gateway being advertised on your storage network at all.