# Routing question



## robss (Apr 16, 2014)

Hi FreeBSDers,

I'm new to FreeBSD, and am having some trouble setting up a simple router with two NICs.  

computer --> ue0 --> router --> re0 --> ISP gateway to Internet

I would like pings from a computer connected to ue0 to be delivered to the Internet.  I would appreciate any thoughts on how to trouble-shoot this. 

The following is my rc.conf

```
hostname="myhost"
ifconfig_re0="DHCP"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"

gateway_enable="YES"
ifconfig_ue0="inet 192.168.119.1 netmask 255.255.255.0"
defaultrouter="192.168.1.254"
```

Output from `netstat`

```
Routing tables

Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            192.168.1.254      UGS         0        0    re0
127.0.0.1          link#2             UH          0        0    lo0
192.168.1.0/24     link#1             U           0        0    re0
192.168.1.83       link#1             UHS         0        0    lo0
192.168.119.0/24   link#3             U           0        0    ue0
192.168.119.1      link#3             UHS         0        0    lo0

Internet6:
Destination                       Gateway                       Flags      Netif Expire
::/96                             ::1                           UGRS        lo0
::1                               link#2                        UH          lo0
::ffff:0.0.0.0/96                 ::1                           UGRS        lo0
fe80::/10                         ::1                           UGRS        lo0
fe80::%lo0/64                     link#2                        U           lo0
fe80::1%lo0                       link#2                        UHS         lo0
ff01::%lo0/32                     ::1                           U           lo0
ff02::/16                         ::1                           UGRS        lo0
ff02::%lo0/32                     ::1                           U           lo0
```

Output from `ifconfig`

```
re0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=8209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC,LINKSTATE>
	ether e0:3f:49:6e:25:cc
	inet 192.168.1.83 netmask 0xffffff00 broadcast 192.168.1.255 
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
	media: Ethernet autoselect (100baseTX <full-duplex>)
	status: active
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 
	nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
ue0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=80008<VLAN_MTU,LINKSTATE>
	ether 8c:ae:4c:fe:9d:10
	inet 192.168.119.1 netmask 0xffffff00 broadcast 192.168.119.255 
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
	media: Ethernet autoselect (none)
	status: no carrier
```

When ue0 is connected to another computer, the connected computer can successfully ping, 192.168.119.1, the address assigned to ue0.  However, pings to 192.168.1.83 do not get returned.  I have tried to add a route between the two nics, but am told that the route already exists.  No firewall is running.

Any thoughts?

Thanks,
Rob


----------



## SirDice (Apr 16, 2014)

Your routing table looks good, so that's not the problem. What can you see when you run tcpdump(1) on the router? Using a tool like tcpdump(1) can help to "see" what's going on.


----------



## usdmatt (Apr 16, 2014)

So your basic setup is something like the following?


```
ISP Gateway (Assuming some sort of router itself): 192.168.1.254
|
FreeBSD Machine: 192.168.1.83 (re0 DHCP)
FreeBSD Machine: 192.168.119.1 (ue0)
|
Client PC: 192.168.119.x
```

I can't see an obvious reason why you shouldn't be able to ping the 'other side' of the FreeBSD router with the setup you have so far. I don't use FreeBSD as a router much so I may have missed something obvious. The client machine will need its default gateway set to 192.168.119.1 of course.

The first this I do see as being a problem is that the Internet gateway (192.168.1.254) is not going to know how to get back to the 192.168.119.x subnet. It will know it has 192.168.1.x on its LAN interface, and will route everything else via its default route, which will probably be via its WAN. As such, the Internet gateway will likely need a route added to it such as the following (which may also need your FreeBSD machine to have a static address on that network):


```
route add 192.168.119.0/24 192.168.1.83
```

If you don't have the ability to add routes to the Internet gateway router, you'll probably have to run NAT on the FreeBSD box so the Internet gateway only sees packets coming from the 192.168.1.x network.


----------



## alexseitsinger (Jun 3, 2014)

Hello,

Default gateway should be the Gateway provided by your ISP. You can find this by running 'netstat -nr' when directly connected to your modem. The first hop(line) that appears is your connection to your ISP. The second column titled 'gateway' will give you the IPv4 address for your default gateway. However, this might not be necessary to set.

In order for the packets to travel from your LAN to the internet you will need to configure one of the firewalls to NAT(translate) the packets IP( which is the the LAN IP ) into the public IP ( which is the WAN IP from your modem that is connected to your ISP ).  PF, or Packet Filter, comes enabled on the 10.0 kernel automatically so I would suggest using that. To learn how to do this search google for "FreeBSD PF nat/firewall" and you should be up and running once you have that enabled.

Best,
Alex


----------

