problem with host ip and gateway are on different networks

Hello, all.

I am facing with this issue where the ip address and the default gateway are on different networks. FreeBSD just won't allow setting the default route.

This host ip is 10.0.2.100/24. The GW is 10.0.0.254. There is no GW for 10.0.2.0.

I got this error when adding the default GW with rc.conf or route add
Code:
(route: writing to routing socket: Network is unreachable
add net default: gateway 10.0.0.254: Network is unreachable

As you might know that Windows and Linux OSes are ok with using the gateway that is different from its network.

How can I fix this problem on a FreeBSD box?

Thanks.
 
The problem might be that the gateway is not on a directly connected network so you must also list the next-hop gateway.
 
This is not possible. Windows will indeed accept it but I highly doubt linux will.

Having a default gateway outside of your subnet simply breaks the protocol, hence it's not possible to set it like that on FreeBSD.
 
bossadvisor said:
Hello, all.

I am facing with this issue where the ip address and the default gateway are on different networks. FreeBSD just won't allow setting the default route.

This host ip is 10.0.2.100/24. The GW is 10.0.0.254. There is no GW for 10.0.2.0.

I got this error when adding the default GW with rc.conf or route add
Code:
(route: writing to routing socket: Network is unreachable
add net default: gateway 10.0.0.254: Network is unreachable

As you might know that Windows and Linux OSes are ok with using the gateway that is different from its network.

How can I fix this problem on a FreeBSD box?

Thanks.

I don't know how FreeBSD stack/options are implemented fully, but in a case like this a host might ARP for GW, and local router will proxy ARP for GW, making this work.
This isn't ideal since a local network does have its default gateway, you just don't know what it is/means obviously.
There could be a way to make FreeBSD ARP for this GW, I'm not sure.
 
You can try something like this, but I have no idea if it actually works (or if the syntax is 100% correct).

Code:
route add default -iface rl0
That's assuming the rl0 interface is the one connected to the network.

I have to use a similar construct to get my machine online using SIP spoofing. Which results in DHCP serving me a gateway address outside of my subnet.

Code:
route add -net 10.0.0.138 -iface rl0
route add default 10.0.0.138
The 10.0.0.138 address is my speedtouch ADSL modem.
 
SirDice said:
You can try something like this, but I have no idea if it actually works (or if the syntax is 100% correct).

Code:
route add default -iface rl0
That's assuming the rl0 interface is the one connected to the network.

Yeah, that's basically variation of it.
Note that this will ARP for every single IP you want to connect to, filling up your ARP table and slowing you down considerably. Also the router needs proxy ARP enabled. Hosts have crashed this way.
 
You don't need to add a route for each host.
Just add the route to the real gateway address and then add the default route:
Code:
/sbin/route add -host 10.0.0.254 -iface rl0
/sbin/route add default 10.0.0.254
I used a similar approach on OpenBSD 3.x few years ago and it worked.
PS: The router (10.0.0.254) must be aware of the directly connected address 10.0.2.100. This kind of subnetting problem should not be fixed this way unless a proper method is not available or too expensive to apply.
 
Thanks everyone for your input.
ecazamir's instructions allows the FreeBSD box to talk to other networks. Thanks ecazamir!

[cmd=]/sbin/route add -host 10.0.0.254 -iface rl0[/cmd] (replace rl0 with your own box interface name)
[cmd=]/sbin/route add default 10.0.0.254[/cmd]
 
hello

I have the same problem on OVH server and this is their instruction:

FreeBSD 8.0
WARNING: Under no circumstances use the primary IP of your server as the gateway! You must under no circumstances use: [cmd=]route add default gw dev eth0[/cmd] or you could cut your IP from the virtual server.

/etc/rc.conf
Code:
ifconfig_em0="inet IP.FAIL.OVER netmask 255.255.255.255 broadcast IP.FAIL.OVER"
static_routes="net1 net2"
route_net1="-net IP.DE.VOTREDEDIE.254/32 IP.FAIL.OVER"
route_net2="default IP.DE.VOTREDEDIE.254"

/etc/resolv.conf
Code:
nameserver 213.186.33.99

And this is what I have made it on my FreeBSD 7.0-RELEASE:
Code:
ifconfig_le0="inet 188.165.55.10 netmask 255.255.255.255 broadcast 188.165.55.10"
static_routes="net1 net2"
route_net1="-net 188.165.196.254/32 188.165.55.10"
route_net2="default 188.165.196.254"

Main ip for the host: 188.165.196.95
Gateway for the host: 188.165.196.254
And my vmware ip: 188.165.55.10

So is there any way to help me because when try to do that found this error:

Code:
/usr/src/lib/bind/isc/../../../contrib/bind9/lib/isc/unix/socket.c:1179: internal_send: 213.186.33.99#53: Invalid argument
and /var/log/messages:
Code:
kernel: arplookup 188.165.196.254 faild: host is not on local network

kernel: arpresolve: can't allocate route for 188.165.196.254
 
Does that mean it isn't possible or what? I didn't get a reply, why? What can I do if I didn't find a solution on this forum? Does that mean I should change to a different OS?
 
so if there some one can tell me how can i make this
FreeBSD Multicast Roting Configuration

Multicast routing requires that support be compiled into the kernel with the following option:
Code:
options MROUTING
 
OVH Network problem with host ip and gateway are on different networks

[ Merged in - do not start a new topic when you're already in an existing one -- Mod. ]

Hello, all.

I am facing with this issue where the ip address and the default gateway are on different networks. FreeBSD 7.4 just won't allow setting the default route.

This host ip is 188.165.55.10. The GW is 188.165.196.254. There is no GW for 188.165.55.10.


and this is OVH instruction to make it work but for FreeBSD 8.00:

FreeBSD 8.0
WARNING: Under no circumstances use the primary IP of your server as the gateway! You must under no circumstances use: route add default gw dev eth0 or you could cut your IP from the virtual server.

/etc/rc.conf

Code:
ifconfig_re0="inet IP.FAIL.OVER netmask 255.255.255.255 broadcast IP.FAIL.OVER"
static_routes="net1 net2"
route_net1="-net IP.DE.VOTREDEDIE.254/32 IP.FAIL.OVER"
route_net2="default IP.DE.VOTREDEDIE.254"

/etc/resolv.conf

Code:
nameserver 213.186.33.99

And this is what I have made it on my FreeBSD 7.0-RELEASE:
Code:
ifconfig_re0="inet 188.165.55.10 netmask 255.255.255.255 broadcast 188.165.55.10"
static_routes="net1 net2"
route_net1="-net 188.165.196.254/32 188.165.55.10"
route_net2="default 188.165.196.254"

So is there any way to help me because when try to do that found this error :

ping 188.165.196.95

Code:
/usr/src/lib/bind/isc/../../../contrib/bind9/lib/isc/unix/socket.c:1179: internal_send: 213.186.33.99#53: Invalid argument

and when add this route :

Code:
route add -host 188.165.196.254 -iface re0

the error didn't appear but found this error :
/var/log/messages:
Code:
kernel: arplookup 188.165.196.254 faild: host is not on local network

kernel: arpresolve: can't allocate route for 188.165.196.254

also found this When search in google:

FreeBSD Multicast Roting Configuration

Multicast routing requires that support be compiled into the kernel with the following option:

Code:
options MROUTING

tring rebuild kernel with PAE because also i want support 16 GB and add this option in PAE file after PAE section

/usr/src/sys/i386/conf/PAE

Code:
# To make a PAE kernel, the next option is needed
options		PAE			# Physical Address Extensions Kernel
options		MROUTING
and build the kernel and same thing problem didn't solve :( :(

how can i make if this option for MROUTING build with new kernel

Thank's In advanced
 
I can only tell that your hosting provider uses quite odd configurations.

Code:
kernel: arpresolve: can't allocate route for 188.165.196.254
means that the kernel is unable to create arp entry (link level route) for the gateway, which may be correct, since your interface does not have any ip address in the specified network.
Code:
/usr/src/lib/bind/isc/../../../contrib/bind9/lib/isc/unix/socket.c:1179: internal_send: 213.186.33.99#53: Invalid argument
is related only to ISC BIND's function. If your machine is a DNS server, then dig into this matter if the named process is unable to work properly, i.e. serve DNS requests / transfers. Use /usr/bin/dig will help you to find if DNS is working properly. If your machine IS NOT a DNS server, the message may be related to the resolver library and it should affect only DNS queries sent from your server to other DNS servers. Try adding a different resolver to /etc/resolv.conf (8.8.8.8 is a working example) or use diagnostic tools such as 'dig', 'nslookup' and 'host'.

Use of MROUTING kernel option is not relevant, as long as you do not forward multicast traffic. This option is required if the following requirements are met:
- the machine is a router
- this router must forward multicast traffic in addition to unicast
 
Hello,

Thank ecazamir for reply. I know the provider is the problem with his networking and can't change anything in their network but when I install FreeBSD 8.2 it's working with their instructions. The problem is just in 7.2.

Also the server didn't do DNS server and try this with fresh install and same problem. When I change the IP in /etc/resove.conf there is the same error with the new IP. I am sure this IP works on other servers fine.

Also I tried the command which you give to me and I will attach the pic for output. Finally I think MROUTING helps me to do setup of the IP on the gateway on other networks.
 
Let me understand:
Code:
arpresolve: can't allocate route for 188.165.196.254
has any negative effect on network operation? I understand that this message
Code:
/usr/src/lib/bind/isc/../../../contrib/bind9/lib/isc/unix/socket.c:1179: internal_send: 213.186.33.99#53: Invalid argument
disappears when you configure the route.
I'm not so sure that enabling multicast will help too much, but it is possible to get rid of the
Code:
can't allocate route for 188.165.196.254 / "arpresolve: can't allocate route for ...
messages.
PS: The proper file name is /etc/resolv.conf.
 
You could also try this method - on the first host 10.0.2.100 use 255.0.0.0 as subnetmask instead and enable proxy-arp on the gateway ; similar for 188.165.55.10 , use 255.255.0.0
 
jtom said:
You could also try this method - on the first host 10.0.2.100 use 255.0.0.0 as subnetmask instead and enable proxy-arp on the gateway ; similar for 188.165.55.10 , use 255.255.0.0

Hello

Could you please some explain for your step and tell me if you have this problem and solve it before please.
 
maskmoataz said:
Hello

Could you please some explain for your step and tell me if you have this problem and solve it before please.

I'm not sure I understand what you are asking. What I explained above is called proxy-arp and it works by tricking the host into thinking it is on the same LAN as the gateway even though it is not - however for this to work proxy-arp has to be enabled on the gateway.
 
Back
Top