# Setup gateway



## 2trill2spill (Feb 9, 2015)

I have two boxes with FreeBSD 10.1 on them. One I have been trying to setup as a router/gateway to the internet and the other to connect to the LAN network created by the previous box. The router box is able to ping both google(8.8.8.8) and the second box on the LAN network. The Second box can ping the router but is unable to ping google. So how can I get the Router to route traffic to and from the internet to my second box. Also I have the packet filter turned off. Any help would be appreciated.

Here is the routers /etc/rc.conf and routing tables.


```
hostname="router.sercurelabs.com"
ifconfig_igb0="inet 10.1.10.2 netmask 255.255.255.0"
ifconfig_igb1="inet 192.168.1.1 netmask 255.255.255.0"

sshd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
zfs_enable="YES"

defaultrouter="10.1.10.1"

gateway_enable="YES"

static_routes="lan"
hostname="router.sercurelabs.com"
ifconfig_igb0="inet 10.1.10.2 netmask 255.255.255.0"
ifconfig_igb1="inet 192.168.1.1 netmask 255.255.255.0"

sshd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
zfs_enable="YES"

defaultrouter="10.1.10.1"

gateway_enable="YES"

static_routes="lan"
route_lan="-net 192.168.1.0/24 192.168.1.1"

ntpd_enable="YES"
openntpd_enable="YES"
openntpd_flags="-s" # sync time at boot, and afterwar:w

sendmail_enable="NO"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"

dhcpd_enable="YES"
dhcpd_flags="-q"
dhcpd_conf="/usr/local/etc/dhcpd.conf"
dhcpd_ifaces="re0"
dhcpd_withumask="022"
dhcpd_chuser_enable="YES"
dhcpd_withuser="dhcpd"
dhcpd_withgroup="dhcpd"
dhcpd_chroot_enable="YES"
dhcpd_devfs_enable="YES"
dhcpd_rootdir="/usr/chroot/dhcpd"

# Syslog
syslogd_flags="-ss" # do not bind to any address

##############################

Internet:
Destination  Gateway  Flags  Netif Expire
default  10.1.10.1  UGS  igb0
10.1.10.0/24  link#1  U  igb0
10.1.10.2  link#1  UHS  lo0
127.0.0.1  link#3  UH  lo0
192.168.1.0/24  link#2  U  igb1
192.168.1.1  link#2  UHS  lo0
```


Here is the Second boxes /etc/rc.conf and routing tables.


```
hostname="loki"
ifconfig_igb0="inet 192.168.1.17 netmask 255.255.255.0"
sshd_enable="YES"
defaultrouter="192.168.1.1"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
zfs_enable="YES"

######################

Internet:
Destination  Gateway  Flags  Netif Expire
default  192.168.1.1  UGS  igb0
127.0.0.1  link#5  UH  lo0
192.168.1.0/24  link#1  U  igb0
192.168.1.17  link#1  UHS  lo0
```


----------



## usdmatt (Feb 9, 2015)

I haven't had a proper look though but first thoughts:


I assume you've pasted some of the config twice and haven't configure the interfaces twice in rc.conf (Not that it really matters as it's all just variables so the second set would override the first)
I don't think you need that LAN static route on the router box. Everything with a 192.168.1.0/24 address should be directly reachable via igb1, and the system will have a route as such created automatically just by having 192.168.1.1/24 assigned to igb1. It's called a connected route and doesn't need to be created manually
You don't appear to be using NAT.  Not that you should if you can get away with it, but in that case, how does the device on the wan side of the router, 10.1.10.1, know how to get to the 192.168.1.0 network? The default route on 10.1.10.1 will probably be out to the Internet. It needs to know that to access 192.168.1.0/24, it needs to forward the packets to 10.1.10.2.


----------



## 2trill2spill (Feb 9, 2015)

Yea you are right about pasting in part of /etc/rc.conf twice.

10.1.10.1 is the modem from my ISP, so do I have to enable NAT on the FreeBSD router so that the modem knows how to route traffic to 192.168.1.0/24 because I don't believe I can configure the modem?


----------



## usdmatt (Feb 9, 2015)

Sounds like it. Without the ability to add routes to the ISP modem/router, it's never going to know how to reach hosts on the 192.168.1.0 network. With NAT all those hosts will hide behind 10.1.10.2, which the modems knows how to reach, and the BSD router will handle getting packets back to the correct place.


----------

