2

I wish to add static route for my interface eth1. But Whenever I use route command , I get this annoying error RTNETLINK answers: Invalid argument.

Current routing configuration

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

10.73.55.172 0.0.0.0 255.255.255.252 U 0 0 0 eth2 10.64.23.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 1004 0 0 eth2 169.254.0.0 0.0.0.0 255.255.0.0 U 1005 0 0 eth3 0.0.0.0 10.73.55.173 0.0.0.0 UG 0 0 0 eth2

For eth0 , I want to have default gateway 10.64.23.1 and for eth2 , I want to have gateway as 10.73.55.173. By configuration is as follows:

ifconfig eth0

eth0 Link encap:Ethernet HWaddr 28:80:23:AF:E0:4C inet addr:10.64.23.36 Bcast:10.64.23.255 Mask:255.255.255.0 inet6 addr: fe80::2a80:23ff:feaf:e04c/64 Scope:Link

ifconfig eth2 eth2 Link encap:Ethernet HWaddr 28:80:23:AF:E0:4E inet addr:10.73.55.174 Bcast:10.73.55.175 Mask:255.255.255.252 inet6 addr: fe80::2a80:23ff:feaf:e04e/64 Scope:Link

I am using CentOS release 6.4

cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
#HWADDR="28:80:23:AF:E0:4C" IPADDR=10.64.23.36
#IPV6INIT="yes" NETMASK=255.255.255.0
#NM_CONTROLLED="no" ONBOOT=yes GATEWAY=10.64.23.1 TYPE="Ethernet" UUID="bdb726be-c3ce-404d-ba56-7a46906745af"

MAL_SIG_1_8_1:/home/mclaw# cat /etc/sysconfig/network-scripts/ifcfg-eth2 DEVICE="eth2" BOOTPROTO="static" IPADDR=10.73.55.174 #DHCP_HOSTNAME="mc-inst" #HWADDR="28:80:23:AF:E0:4E" #NM_CONTROLLED="yes" NETMASK=255.255.255.252 GATEWAY=10.73.55.173 ONBOOT="yes" #DEFROUTE=no TYPE="Ethernet" UUID="5be9a274-6146-4ad0-9135-7fcc612ec2b7"

MAL_SIG_1_8_1:/home/mclaw# cat /etc/sysconfig/network NETWORKING=yes HOSTNAME=MAL_SIG_1_8_1 #GATEWAY=10.64.23.1

Whatever ip route command , I give it gives me following error.

ip route add 10.73.55.174/30 via 10.73.55.173 dev eth2

RTNETLINK answers: Invalid argument

Tero Kilkanen
  • 38,887

2 Answers2

1

When adding routes with IP route, one needs to use always network addresses.

10.73.55.174/30 is not a valid network address. Network address is always the first IP address in a subnet. In your case, the network address is 10.73.55.172/30.

Your routing table already has an entry for that subnet.

Tero Kilkanen
  • 38,887
0

Keep in mind that this route is not persistent, so after every reboot you lose your gateway for eth2

I would set the gateway for eth2 like this

sudo vi /etc/sysconfig/network-scripts/ifcfg-eth2

For example

DEVICE="eth2"
BOOTPROTO="static"
IPADDR=10.73.55.174
NETMASK=255.255.255.252
GATEWAY=10.73.55.173
ONBOOT="yes"
TYPE="Ethernet"
Turdie
  • 2,945