1

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
  • 36,796
  • 3
  • 41
  • 63
user1107731
  • 111
  • 1
  • 1
  • 2

1 Answers1

0

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
  • 36,796
  • 3
  • 41
  • 63
  • With network address I got " No such process error". When I try to use one link it works. – user1107731 Nov 09 '20 at 18:26
  • Although entries are there in routing table , there is no gateway. With network address I got " No such process error". When I try to use one link it works. ip route add 10.73.55.172/30 via 10.73.55.173 dev eth2 onlink. This command works and give me correct output. Now I need to know how to set this in route-eth2 so that after reboot it works. This line in route eth2 does not work properly 10.73.55.172/30 via 10.73.55.173 eth2 onlink. It gives me following error RTNETLINK answers: No such device – user1107731 Nov 09 '20 at 18:55
  • https://drive.google.com/file/d/1wu91FWSjf1asuhfbZxzVwTxON5A1RzYa/view?usp=sharing – user1107731 Nov 09 '20 at 19:02
  • In the link , I have attached the commands and route options with error shown when trying to add it in route-eth2 – user1107731 Nov 09 '20 at 19:03