Solved IPv4 stopped working on FreeBSD 13.1-RELEASE; manually set it to access Internet

My Internet wasn't working properly, and I wasn't able to ping my router. Some Internet sites worked, while others didn't. Used a live Linux CD, and the Internet was fine, and I could ping my router from it. That showed that the problem wasn't my router or the Ethernet cable.

It turns out that sites that used IPv6 worked, while IPv4 wasn't functioning on my FreeBSD 13.1-RELEASE machine. ping6 and traceroute6 worked from FreeBSD. ifconfig showed the IPv6 information, but lacked the IPv4 information.

DHCP gave error messages in the bootup. A similar error message from trying to load it from the command line was:
Code:
ifconfig: WARNING: setting interface address without mask is deprecated,
default mask may not be correct.

Setting it manually with CIDR notation without DHCP got it to work. Manually setting it wouldn't work without CIDR notation anymore.

rc.conf:
Code:
ifconfig_re0="inet 192.168.1.115/16"
Then loading it on the command line:
ifconfig re0 inet 192.168.1.115/16
service netif restart
service routing restart

This last line also allowed it to be restarted without a reboot. Then, it worked.

Not sure if I messed up a setting for DHCP without realizing it for it to stop working. The error message gives a depreciation warning. I recompiled the kernel, but don't remember making a recent base update. dhclient(8) is relevant for DHCP. Maybe this will help someone figure out what to do if their Internet from FreeBSD stops working correctly.
 
Try to set it this way, assuming your default gateway is 192.168.1.1 with /24 (255.255.255.0) netmask.

/etc/rc.conf
ifconfig_re0="inet 192.168.1.115 netmask 255.255.255.0"
defaultrouter="192.168.1.1"

EDIT:
Sorry i didn't read correctly your message. Check your DHCP configuration on the router and verify the network mask there. Also you can debug it using tcpdump to see exactly what IP/ mask you are receiving via DHCP for troubleshooting.

Initially i was thinking that rc.conf was unable to set correctly your IP address via CIDR defined in it but after second read you have issue with the DHCP on your router so my mistake and you can ignore my first recommendation.
 
rc.conf:
Code:
ifconfig_re0="DHCP netmask 255.255.255.0"
This works, but it seems like a hack with errors. I had the defaultrouter set.

Without that notation, I was applying the mask incorrectly when troubleshooting before. I crossed out something, because I realized that part may not have been correct, after I saw your response.

Edit: I either made a mistake in my configuration file earlier, and didn't catch it, Or the correct behavior timed out after a given time, and it needed the netmask set. Not sure what happened. Trying the old setting of DHCP without a netmask works after a reboot.

Updated edit:
It was probably somehow related to disabling devd. As someone else mentioned it too. Maybe devd compensated for an obsolete setting.

My IPv6 settings, in rc.conf:
Code:
ifconfig_re0_ipv6="inet6 accept_rtadv"
This and IPv6 enabled on my gateway allowed me to continue accessing FreeBSD's website from my computer.
 
To debug the DHCP comment out your #ifconfig_re="...." and #defaultrouter in /etc/rc.conf then restart wihtout network after restar in ttyv1 start the tcpdump and in ttyv0 manually start DHCP client using dhclient re0 and observe the following in ttyv1


tcpdump -i re0 port 67 or port 68 -e -n -vvv

Code:
08:25:06.902232 00:xx:xx:xx:xx:xx > ff:ff:ff:ff:ff:ff, ethertype IPv4 (0x0800), length 357: (tos 0x0, ttl 128, id 6401, offset 0, flags [none], proto UDP (17), length 343)
    10.0.xx.xx.67 > 255.255.255.255.68: [udp sum ok] BOOTP/DHCP, Reply, length 315, xid 0x1b72274a, Flags [none] (0x0000)
          Your-IP 10.0.1.81
          Client-Ethernet-Address 00:xx:xx:xx:xx:xx
          Vendor-rfc1048 Extensions
            Magic Cookie 0x63825363
            DHCP-Message Option 53, length 1: ACK
            RN Option 58, length 4: 345600
            RB Option 59, length 4: 604800
            Lease-Time Option 51, length 4: 691200
            Server-ID Option 54, length 4: 10.0.xx.xx
            Subnet-Mask Option 1, length 4: 255.255.255.0
            Default-Gateway Option 3, length 4: 10.0.1.1
            Domain-Name Option 15, length 19: "xxxx.xxxxx.com^@"
            Domain-Name-Server Option 6, length 12: 10.0.xx.xx,10.0.xx.xx,10.0.xx.xx
            END Option 255, length 0
 
What I gathered here was adding a defaulrouter="192.168.132.1" to the /etc/rc.conf I didn't need that in BSD 13. But, with some extra NIC's added, I often have to specify the connection speed with mediaopt so the NIC operates at the gigabit speed.
defaultrouter="192.168.xxx.1"
ifconfig_em1="192.168.xxx.96 netmask 0xffffff00 media 1000baseTX mediaopt full-duplex"

** Thanks for the Help
 
Back
Top