# Routing problem



## balanga (Oct 3, 2017)

I have a FreeBSD installation in which networking has been working normally for quite a while but all of a sudden I am unable to ping anything outside my LAN. I may well have changed something unwittingly as I am prone to tinkering, but I thought that routing is pretty straightforward when using DHCP... 

Since routing has always 'just worked' I'm not even sure where routing information is stored. Can anyone suggest what I should check?

I running FreeBSD 11.0-RELEASE-p1 i386 on a ThinkPad X61.

/etc/rc.conf contains:

```
ifconfig_em0="DHCP"
```

The system does get an IP address assigned from the DHCP server and I am able to access the Internet from other systems as well as from other FreeBSD installations on this system.

As an aside I get a Segmentation fault when running `gpart show` so there may be some underlying fault which I don't know about.


----------



## aragats (Oct 3, 2017)

It would be good to see your routing table (`netstat -r`).


----------



## SirDice (Oct 4, 2017)

I would add the -n switch; `netstat -rn`. The -n will stop netstat(1) from trying to reverse resolve the addresses. It takes a bit of time to do that and I find it fairly useless, I prefer to have the full IP addresses for routing tables not their resolved host or network names. It just makes it a little easier to understand it.


```
Internet:
Destination        Gateway            Flags     Netif Expire
default            192.168.10.1       UGS         em0
127.0.0.1          link#3             UH          lo0
192.168.10.0/24    link#2             U           em0
192.168.10.190     link#2             UHS         lo0
192.168.10.202     link#2             UHS         lo0
192.168.10.202/32  link#2             U           em0
```
Look for the default route. You should have one, especially if the machine gets its IP from DHCP. Try pinging that address (192.168.10.1 in my example).


----------



## balanga (Oct 4, 2017)

`netstat -rn`
`Routing tables
(0) (0) UH 16120
(0) (0) UH 16120
(0) (0) U 16120
(0) (0) UH 16120`

????!!!!!

On booting I noticed:-

```
route: writing to routing socket: Invalid argument
```

This doesn't appear in dmseg which I find susrprising....


----------



## SirDice (Oct 4, 2017)

Ok, that looks like DHCP failed for some reason and now the machine doesn't even have an IP address. Did you enable a firewall perhaps? That could be blocking the DHCP requests.


----------



## balanga (Oct 5, 2017)

```
route: writing to routing socket: Invalid argument
add host 127.0.0.1: gateway lo0 fib 0: Invalid argument
route: writing to routing socket: Invalid argument
add host ::1: gateway lo0 fib 0: Invalid argument
route: writing to routing socket: Invalid argument
add net fe80::: gateway ::1 fib 0: Invalid argument
route: writing to routing socket: Invalid argument
add net ff02::: gateway ::1 fib 0: Invalid argument
route: writing to routing socket: Invalid argument
add net ::ffff:0.0.0.0: gateway ::1 fib 0: Invalid argument
route: writing to routing socket: Invalid argument
add net ::0.0.0.0: gateway ::1 fib 0: Invalid argument
Starting local_unbound.
Waiting for nameserver to start... good
Waiting 30s for default route interface:......
```

I do get an IP address assigned which is pingable from elsewhere on the LAN...

I'm not sure where routing information is held so am not sure what to check, but it looks as though it is not getting written properly. Could this be a filesystem fault?  `netstat` is not showing anything meaningful regarding routing.


----------



## usdmatt (Oct 5, 2017)

Have you managed to mess up (or not finish) an upgrade? The gpart and Invalid argument errors tend to suggest something fundamental is wrong, and having out of sync userland/kernel would be my obvious choice.


----------



## balanga (Oct 6, 2017)

usdmatt said:


> Have you managed to mess up (or not finish) an upgrade? The gpart and Invalid argument errors tend to suggest something fundamental is wrong, and having out of sync userland/kernel would be my obvious choice.



I'm sure there is something fundamentally wrong, but how do I fix it?

I have not tried to apply an upgrade for several months. I do have another FreeBSD installation on the same disk which does not have these problems. Is there any way I can compare the two installations in order to highlight the differences and maybe pinpoint the source of the problem?


----------

