Re: Cannot route through an if without ip

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

antonio.dibacco a écrit :

I have an ethernet (eth1) without any assigned ip, nevertheless I would like to route through this IF but issueing the following command gives an error:
route add -net 192.168.1.0 dev eth1

When I type this command I get an error because 192.168.1.0 is not a subnet, I must add a mask or prefix length, for instance :

route add -net 192.168.1.0/24 dev eth1

If the same IF has an address the command will be correctly executed.
Why?

The interface has to be up and bound to IPv4. You can check this when directory /proc/sys/net/ipv4/conf/eth1 exists. To force this without assigning an address to the interface, just execute the following command :

ifconfig eth1 0.0.0.0 up

The default source address used in locally generated packets will be chosen among addresses assigned to other interfaces. You can assign it statically creating the route with 'ip' instead of 'route' :

ip route add 192.168.1.0/24 dev eth1 src $LOCAL_IP

where $LOCAL_IP is a local address assigned to any interface but the loopback.

Note there are possible issues regarding routing and ARP if you expect to receive IPv4 traffic on eth1. - Routing : hosts on the network reachable on eth1 must have appropriate route(s) to the box addresse(s). - ARP : your box must accept and reply to ARP requests about any local address received on eth1. For this, make sure the kernel parameters arp_filter, arp_announce and arp_ignore in /proc/sys/net/ipv4/conf/eth1 have appropriate value (default values 0 should be fine). Or you can add static ARP entries on the hosts reachable on eth1.

PS: Any feedback about my reply to your previous question ?



[Index of Archives]     [Linux Netfilter Development]     [Linux Kernel Networking Development]     [Netem]     [Berkeley Packet Filter]     [Linux Kernel Development]     [Advanced Routing & Traffice Control]     [Bugtraq]

  Powered by Linux