# Static IP problem connecting to internet



## Dimitri (Sep 10, 2019)

Greetings
I have a fresh install of FreeBSD 12 that I am trying to configure to connect to the internet over ethernet cable.
I am fairly certain that the settings provided by my ISP are correct because when I connect a elementaryOS laptop with those settings to the ethernet cable there is Internet access.
When I connect my FreeBSD computer however, ping 8.8.8.8 yields sendto: No route to host

rc.conf is as follows:

```
hostname="mail1.xxx.com"
ifconfig_nfe0="inet xxx.50.247.150 netmask 255.255.255.248"
defaultrouter="xxx.50.247.145"
sshd_enable="YES"
dumpdev="AUTO"
```
resolv.conf contains the appropriate nameserver addresses.

Does anyone have any ideas on what to try next to get the connection to work?
Thanks in advance


----------



## sidetone (Sep 10, 2019)

After you update settings, use `service resolv onerestart`, `service routing onerestart` and `service netif onerestart`, so you won't have to reboot after you adjust settings.

resolv.conf

```
search routernameaddress.net
nameserver 192.168.1.254
nameserver xxxx:xxxx:xxx:xxxx::1  #ipv6
options edns0
```

In rc.conf, use automatic settings, then get the results of `ifconfig` and fill in the values for rc.conf. Also get settings from your router's diagnostics and your computer's `traceroute` and `traceroute6`for rc.conf values. It's better to set the default router for each ipv4 and if you're using ipv6.

On my setting for defaultrouter, I have 192.168.1.254. That's generic for IPv4.


----------



## Dimitri (Sep 10, 2019)

Can you elaborate on what you mean by "In rc.conf, use automatic settings, "


----------



## tommiie (Sep 10, 2019)

sidetone said:


> On my setting for defaultrouter, I have 192.168.1.254. That's generic for IPv4.


What do you mean, "that is generic for IPv4"?


----------



## tommiie (Sep 10, 2019)

Dimitri said:


> Does anyone have any ideas on what to try next to get the connection to work?



I suggest basic troubleshooting.

Can you ping your default gateway?
Does your routing table (`netstat -r`) show your default route correctly?
Can you do a traceroute to 8.8.8.8? If not, where does it stop?
Can you resolve domain names?


----------



## Dimitri (Sep 10, 2019)

1. No
2. No
3.No
4. No
Yet when I use the same credentials on a linux flavour machine, everything works. I know very little about freebsd. Is there something in a default installation that needs to be opened up?


----------



## PMc (Sep 11, 2019)

`netstat -rn` would be the logical next step. The error message says that there is the error. It shoudl show something like this:

```
Destination        Gateway            Flags     Netif Expire
default            xxx.50.247.145      UGS         nfe0
127.0.0.1          link#2             UH          lo0
xxx.50.247.144/29   link#1             U           nfe0
xxx.50.247.150      link#1             UHS         lo0
```
We don't want to involve name resolution at this point, we just want basic IP connectivity. Name resolution then comes in the next step.

We may also have a look at `ifconfig nfe0`, and check if we can `ping xxx.50.247.150`  and `ping xxx.50.247.145` (the latter may not always work, depending on the kind of router there is).


----------



## Dimitri (Sep 11, 2019)

netstat -rn returns exactly what you mention above, but in addition there is a section with Internet6 information

ping xxx.50.247.150 works
ping xxx.50.247.145 does not work. Router is juniper os


----------



## tommiie (Sep 11, 2019)

What is the output of ifconfig(8)? If you really entered the settings correctly, then you have an issue with the cabling, the switch, or the router. Or you have installed a firewall on FreeBSD and configured it badly. Might that be the case?


----------



## Dimitri (Sep 11, 2019)

See the screenshot attached of the ifconfig
This is a fresh install so I never configured a firewall explicitly.
Also , somewhere I read that if the IPv6 DNS is not configured there can be problems, but I don't know how to disable IPv6 or to set the nameservers for IPv6


----------



## tommiie (Sep 11, 2019)

It could be me but I don't see a screenshot.


----------



## Dimitri (Sep 11, 2019)

Sorry I had to scale it because the file was too bigView attachment 6882


----------



## SirDice (Sep 11, 2019)

Try pinging your default gateway.


----------



## tommiie (Sep 11, 2019)

He already stated pinging his default gateway does not work. I don't see anything wrong, really. If there is no firewall configured, it must be cabling or the router. But that should not be the case since his linux distro works.


----------



## SirDice (Sep 11, 2019)

If the IP address is indeed correct then there's something wrong on the provider side. If the default gateway cannot be accessed you cannot connect to anything outside of the local network. There's nothing "special" to configure on the FreeBSD side for this.


----------



## tommiie (Sep 11, 2019)

Perhaps the ISP remembers the first MAC address it sees and blocks all other MAC addresses for the first *x* hours?


----------



## PMc (Sep 11, 2019)

Dimitri said:


> netstat -rn returns exactly what you mention above, but in addition there is a section with Internet6 information
> 
> ping xxx.50.247.150 works
> ping xxx.50.247.145 does not work. Router is juniper os



Ack. Yes, ther is ip6 stuff also, but that should not bother us. Some routers do just not answer to a ping to themselves, but would otherwise work.
One more thing to check: run `tcpdump -ni nfe0`, then in another terminal run the `ping xxx.50.247.145` again.


----------



## PMc (Sep 11, 2019)

SirDice said:


> If the IP address is indeed correct then there's something wrong on the provider side. If the default gateway cannot be accessed you cannot connect to anything outside of the local network. There's nothing "special" to configure on the FreeBSD side for this.



Tell me I'm wrong, but I'd think the "no route to host" error comes from the kernel not finding a way to deliver the packet.


----------



## SirDice (Sep 11, 2019)

You get the same error message if you try to access something outside your local network and an incorrect (or not working) gateway.

It's not common to disable pings on a gateway, it interferes with basic troubleshooting and doesn't "improve" security.


----------



## PMc (Sep 11, 2019)

SirDice said:


> It's not common to disable pings on a gateway, it interferes with basic troubleshooting and doesn't "improve" security.



I agree, it's a pain when troubleshooting. But I've seen a lot of these, where you get a reply for traceroute (as soon as you aren't behind a NAT), but not for ping (including my provider). And I've witnessed these "corporate security" discussions.


----------



## Dimitri (Sep 11, 2019)

I will swap out the Network card and report back


----------



## Dimitri (Sep 12, 2019)

Alas, new network card makes no difference on FreeBSD.
I then did a fresh install of linux on the same hardware and the connection works which leaves me to conclude that there is something wrong with my FreeBSD install rather than the router.


----------



## Dimitri (Sep 13, 2019)

Reinstalled FreeBSD and all works correctly now.
Thanks for the help


----------

