# Network configuration on FreeBSD



## PVB (Aug 7, 2017)

Hi Guys,

I have setup a FreeBSD on a beagle bone and am facing networking issues on this setup. All I need is network access on this FreeBSD.

Currently I can ping the gateway but cannot ping ant device that is on the same router. Here is how I have set it up.

I have a router connected to my company network. The router's IP address is 192.168.3.1 I have 2 devices connected to it, 1 beagle bone with freebsd at 192.168.3.5 and one laptop at 192.168.3.3

Now from freebsd, I can ping the router


```
# ping 192.168.3.1
PING 192.168.3.1 (192.168.3.1): 56 data bytes
64 bytes from 192.168.3.1: icmp_seq=0 ttl=255 time=1.318 ms
64 bytes from 192.168.3.1: icmp_seq=1 ttl=255 time=0.647 ms
64 bytes from 192.168.3.1: icmp_seq=2 ttl=255 time=0.615 ms
64 bytes from 192.168.3.1: icmp_seq=3 ttl=255 time=0.658 ms
64 bytes from 192.168.3.1: icmp_seq=4 ttl=255 time=0.655 ms
64 bytes from 192.168.3.1: icmp_seq=5 ttl=255 time=0.604 ms
64 bytes from 192.168.3.1: icmp_seq=6 ttl=255 time=0.665 ms
```
From the laptop I can ping the beagle bone (FreeBSD)


```
PING 192.168.3.5 (192.168.3.5): 56 data bytes
64 bytes from 192.168.3.5: icmp_seq=0 ttl=64 time=0.566 ms
64 bytes from 192.168.3.5: icmp_seq=1 ttl=64 time=0.341 ms
64 bytes from 192.168.3.5: icmp_seq=2 ttl=64 time=0.360 ms
64 bytes from 192.168.3.5: icmp_seq=3 ttl=64 time=0.355 ms
64 bytes from 192.168.3.5: icmp_seq=4 ttl=64 time=0.389 ms
64 bytes from 192.168.3.5: icmp_seq=5 ttl=64 time=0.370 ms
```

However, I cannot ping the laptop from the FreeBSD on beaglebone

```
# ping 192.168.3.3
PING 192.168.3.3 (192.168.3.3): 56 data bytes
```

There is no response from this.

Here is my rc.conf


```
# cat rc.conf
hostname="beaglebone"
#ifconfig_cpsw0=dhcp
ifconfig_cpsw0="inet 192.168.3.5 netmask 255.255.255.0"
defaultrouter="192.168.3.1"
sshd_enable="YES"
#gateway_enable="YES"

# Nice if you have a network, else annoying.
#ntpd_enable="YES"
ntpd_sync_on_start="YES"

# Uncomment to disable common services (more memory)
#cron_enable="NO"
#syslogd_enable="NO"

sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"
```

Any pointers on what I can do to fix this?


----------



## rigoletto@ (Aug 7, 2017)

Hi,

I do not see anything relevant in those config. Is there is anything firewall?  I would try DHCP to see if it would work and how.

Try running `service netif restart && service routing restart` to see what happens.

Also, take a look at /var/run/dmesg.boot for errors.


----------



## Phishfry (Aug 7, 2017)

Also are you sure defaultrouter=192.168.3.1 is correct

192.168.1.1 is what I would use because 192.168.3.0 is a subnet under 192.168.1.0. Just guessing that you are using your router default IP's.

I would try that in addition to the above DHCP recommendation


----------



## PVB (Aug 7, 2017)

I tried the DHCP too. But then I do not even get the ip address


```
# ifconfig
cpsw0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=8000b<RXCSUM,TXCSUM,VLAN_MTU,LINKSTATE>
        ether 50:65:83:c5:73:08
        hwaddr 50:65:83:c5:73:08
        media: Ethernet autoselect (100baseTX <full-duplex>)
        status: active
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
        inet 127.0.0.1 netmask 0xff000000
        groups: lo
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
ping: sendto: No route to host
ping: sendto: No route to host
ping: sendto: No route to host
ping: sendto: No route to host
^C
--- 8.8.8.8 ping statistics ---
4 packets transmitted, 0 packets received, 100.0% packet loss
# ping 192.168.3.1
PING 192.168.3.1 (192.168.3.1): 56 data bytes
ping: sendto: No route to host
ping: sendto: No route to host
ping: sendto: No route to host
^C
--- 192.168.3.1 ping statistics ---
3 packets transmitted, 0 packets received, 100.0% packet loss
# ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1): 56 data bytes
ping: sendto: No route to host
ping: sendto: No route to host
ping: sendto: No route to host
ping: sendto: No route to host
```

The routers ip is 192.168.3.1 as that's what I use to log into the router. I also tried changing the default router to 192.168.1.1 and I basically get the "No route to host" error.


----------



## ondra_knezour (Aug 7, 2017)

Phishfry said:


> 192.168.1.1 is what I would use because 192.168.3.0 is a subnet under 192.168.1.0.



Would be true for /16 nemask and several smaller, but not for /24 (255.255.255.0) used here. From this point of view those are two separate networks and OP's configuration seems OK.

I would guess - laptop is running Windows - default Windows firewall policy is to block incoming ICMP requests, so no answers to ping unless manually allowed.


----------



## PVB (Aug 7, 2017)

ondra_knezour said:


> I would guess - laptop is running Windows - default Windows firewall policy is to block incoming ICMP requests, so no answers to ping unless manually allowed.



I am using a Mac OS Sierra 10.12.4

Also, I cannot do a ping to the google servers 8.8.8.8


----------



## scrappywan (Aug 7, 2017)

If you do re-enable DHCP, make sure to quote that option in /etc/rc.conf. It needs to look like: `ifconfig_cpsw0="DHCP"`


----------



## ralphbsz (Aug 8, 2017)

The configuration in rc.conf looks reasonable.  I personally happen to add "broadcast 192.168.3.255" to it, but that should not be necessary. 

For debugging: Please get us the output from "ifconfig", "netstat -i", and most importantly "netstat -r".  Also: when trying to ping the laptop from the beagle bone, run tcpdump in another window.  That will help debug whether the problem is that the packets don't go out, or that the returning packets are being ignored.  You could even run tcpdump on the laptop too, and see whether the two of them give the same answer.


----------



## PVB (Aug 8, 2017)

Hi guys,

I finally figured out the issue here. when I did the netstat -rn I did not see the default route in there, even though I had it in the rc.conf file. After executing the command 

`route add default 192.168.3.1`

I was able to ping the google server. 


```
root@beaglebone:~ # ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=54 time=10.637 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=54 time=9.994 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=54 time=10.105 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=54 time=9.994 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=54 time=10.095 ms
```


I still cannot ping the local device on the same network from my beagle bone but I have deferred that for later debugging. I will update about that as I figure that out.


----------



## SirDice (Aug 9, 2017)

If you do `service netif restart` the interfaces will be brought down and set back up again. However, downing an interface means the routes of that interface disappear to. You may have been trying to get things working and restarted netif one or more times without realizing this also automatically removes the routing entries. After `service netif restart` don't forget to restart routing too: `service routing restart`.


----------

