1

I have a FreeBSD machine that I'm trying to configure with a static IP address, so I added the following lines to the /etc/rc.conf file

ifconfig_wlan0="inet 192.168.0.20 netmask 255.255.255.0"
defaultrouter="192.168.0.10"

after restarting the network service I can no longer connect to the router. If I ping it I get the message host is down. If I set wlan0 to use DHCP in /etc/rc.conf, I can connect to the router fine, but if I try to set a static IP I can't connect. Any idea what I might be doing wrong here?

  • Have you tried using a static IP with another device or computer? That would help narrow it down to either FreeBSD or the router itself. – Emmanuel Rosa Oct 13 '18 at 2:43
  • Yes, I have a Raspberry Pi running Raspbian and a Windows 10 laptop that both have static IP addresses and are able to connect to the same router. – KKloke Oct 13 '18 at 2:45
  • OK. Your config follows the FreeBSD documentation, so that checks out. Hmm... Other than double-checking the default router IP and that the static IP you're using is within the range the router allows, you can check the router for two things: settings for assigning IPs based on the MAC address and a range of addresses you can exclude from DHCP; these are meant to be used for static IPs. In my experience the router will just take pretty much whatever IP you give it, unless you have an explicit MAC address to IP address mapping. – Emmanuel Rosa Oct 13 '18 at 2:57
  • I do have a range of addresses reserved for DHCP on my router. With my other hosts that have static IP I have assigned addresses outside of this range. For the FreeBSD machine, initially I assigned an IP outside of the range reserved for DHCP. When that didn't work, I set the rc.conf to use DHCP and then recorded the IP address that got assigned. I then tried manually configuring that same IP address in rc.conf, but had the same problem. So I've tried IP addresses both within the reserved range and outside of it, but I am still unable to connect to the router when static IP is configured. – KKloke Oct 13 '18 at 19:05
  • I did find something when comparing the output of ifconfig when I'm using DHCP vs static IP. When I'm using DHCP, it shows that I'm connected to the correct ssid for my router. When I'm using static IP it shows that I'm connected to a different ssid. – KKloke Oct 13 '18 at 19:28
1

Set wlan0 to use DHCP, connect, and ping the router. Find the IP of the default gateway (defaultrouter)

# netstat -r | grep -B1 default

Set this defaultrouter and wlan0 static IP in rc.conf. Restart network

# /etc/rc.d/netif restart wlan0

Check the routing "netstat -r" and make sure the default gateway (defaultrouter) is set correctly. Optionally restart routing

# /etc/rc.d/routing restart

Try to ping the router.

  • I tried this, but I am still unable to connect to the router. I ran netstat -r both using DHCP and then with static IP and the default router is correct in both cases. The only difference is I can ping it when I'm using DHCP but I can't when I'm using static IP. – KKloke Oct 13 '18 at 19:06
  • You'll have to isolate the problem. Is it the router? Client? Network? ... Are you able to ping any other node? Is there a firewall, list of allowed IPs, ... in the router? ... You should come back with an isolated problem. – Vladimir Botka Oct 14 '18 at 8:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.