# problem with gateway and route



## xwwu (Jan 31, 2012)

Dear friends;

There are two network cards: re0 and wlan0. I just want to set up my server to be a wireless rourer with subnet 192.168.1.1/24 based on wlan0 also, so I add following words in /etc/rc.conf:


```
ifconfig_wlan0="inet 192.168.1.1 netmask 255.255.255.0 ssid concordfamily mode 11n channel"
wlans_rt28600="wlan0"
router_enable="YES"
static_routes="internalnet1 internalnet2 net1 net2"
route_internalnet2="-net 192.168.1.0/24 192.168.0.6"
route_internalnet1="-net 192.168.1.0/24 192.168.1.1"
ifconfig_re0="inet 192.168.0.6  netmask 255.255.255.0"
defaultrouter="192.168.0.1"
gateway_enable="YES"
```

But when booting, system says gateway 192.168.1.1 unreachable, and if I:

```
ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1): 56 data bytes
ping: sendto: Host is down
ping: sendto: Host is down
ping: sendto: Host is down
ping: sendto: Host is down
```

What does it mean? And what shall I do?

Thanks!


----------



## bbzz (Jan 31, 2012)

You don't need dynamic routing protocol or static routes. This will suffice:


```
ifconfig_wlan0="inet 192.168.1.1 netmask 255.255.255.0 ssid concordfamily mode 11n channel"
wlans_rt28600="wlan0"
ifconfig_re0="inet 192.168.0.6 netmask 255.255.255.0"
defaultrouter="192.168.0.1"
gateway_enable="YES"
```

It's the other router sitting at 192.168.0.1 that needs to know how to reach wireless network, and vice versa.

But first make sure you have wireless connection working.

http://www.freebsd.org/doc/handbook/network-routing.html
http://www.freebsd.org/doc/handbook/network-wireless.html


----------



## kpa (Jan 31, 2012)

Besides this would be a gross error because you can't have two otherwise identical routes that have different gateway addresses:



> ```
> route_internalnet2="-net 192.168.1.0/24 192.168.0.6"
> route_internalnet1="-net 192.168.1.0/24 192.168.1.1"
> ```


----------



## bbzz (Jan 31, 2012)

It's not that load balancing is not possible, it's that next-hop IP is IP of his interface, nor it makes any sense in his setup.

But, it will be confusing as it is.


----------



## xwwu (Jan 31, 2012)

Thanks bbzz and kpa. I have # the 2 lines:


```
#router_enable="YES"
#route_inrenalnet1="-net 192.168.1.0/24 192.168.1.1"
```

but still can't assign IP address to wlan0 by sysinstall and of course can't ping 192.168.1.1 also.

By the way, how to config 192.168.1.1 as default router of 192.168.1.0/24?

Thanks!


----------



## bbzz (Jan 31, 2012)

You didn't read those links I posted, did you?
There's no sense continuing unless you did.


----------



## xwwu (Jan 31, 2012)

bbzz said:
			
		

> You didn't read those links I posted, did you?
> There's no sense continuing unless you did.



Yes, I have read the 2 links and put:


```
create_args_wlan0="wlanmode hostap"
```

into /etc/rc.conf. I can assign 192.168.1.1 to wlan0 right now. But SSID stays on desktop's screen just several seconds, and then goes away.

Thanks.


----------



## xwwu (Jan 31, 2012)

Put:


```
dhcpd_enable="YES"
dhcpd_ifaces="wlan0"
defaultrouter="192.168.0.1"
defaultrouter="192.168.1.1"
```

into /etc/rc.conf then SSID stay there. but connection restrictedï¼Œeven no any encryption. and I wonder why 2 defaultrouters allow me to assign 192.168.1.1 to wlan0.

Still need help


----------



## SirDice (Jan 31, 2012)

Remove both default gateways. You don't need them. Remove those static routes too. You also don't need those. Both networks are 'directly' connected and thus their route is implied.


----------



## xwwu (Jan 31, 2012)

Thanks SirDice. I will try. The problem is from dhcpd:


```
/usr/local/etc/rc.d/isc-dhcpd restart
dhcpd not running? (check /var/run/dhcpd/dhcpd.pid).
Starting dhcpd.
Internet Systems Consortium DHCP Server V3.1-ESV
Copyright 2004-2010 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Wrote 0 class decls to leases file.
Wrote 0 deleted host decls to leases file.
Wrote 0 new dynamic host decls to leases file.
Wrote 0 leases to leases file.
wlan0: not found
/usr/local/etc/rc.d/isc-dhcpd: WARNING: failed to start dhcpd
```

But wlan0 is there.


----------



## SirDice (Jan 31, 2012)

Can you post your current rc.conf?


----------



## xwwu (Jan 31, 2012)

SirDice said:
			
		

> Can you post your current rc.conf?



Thanks for your help. /etc/rc.conf is:


```
keymap="us.iso"
moused_enable="YES"
saver="daemon"
keyrate="normal"
sshd_enable="YES"
#named_enable="YES"
sendmail_enable="NO"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"
postfix_enable="YES"
accf_data_load="YES"
accf_http_load="YES"
apache22_enable="YES"
apache22_data_accept_enable="YES"
apache22_http_accept_enable="YES"
apache22ssl_enable="YES"
mysql_enable="YES"
courier_authdaemond_enable="YES"
courier_imap_imapd_enable="YES"
courier_imap_imapd_ssl_enable="YES"
courier_imap_pop3d_enable="YES"
courier_imap_pop3d_ssl_enable="YES"
amavisd_enable="YES"
amavis_milter_enable="YES"
#amavis_p0fanalyser_enable="YES"
#amavis_p0fanalyser_p0f_filter="tcp dst port 25"
clamav_clamd_enable="YES"
clamav_freshclam_enable="YES"
spamd_enable="YES"
webmin_enable="YES"
snmpd_enable="YES"
snmpd_flags="-a"
snmptrapd_enable="YES"
snmptrapd_flags="-a -p /var/run/snmptrapd.pid"
snmpd_conffile="/usr/local/share/snmp/snmpd.conf /etc/snmpd.conf"
#mrtg_daemon_enable="YES"
#nfsuserd_enable="YES"
#nfscbd_enable="YES"
#gssd_enable="YES"
inetd_enable="YES"
wlans_rt28600="wlan0"
#router_enable="YES"
static_routes="internalnet1 internalnet2"
route_internalnet2="-net 192.168.1.0/24 192.168.0.6"
#route_internalnet2="-default 192.168.1.1"
dhcpd_enable="YES"
dhcpd_ifaces="wlan0"
create_args_wlan0="wlanmode hostap"
#hostapd_enable="YES"

ifconfig_re0="inet 192.168.0.6 netmask 255.255.255.0"
#defaultrouter="192.168.0.1"
#defaultrouter="192.168.1.1"
hostname="xxx.xxx.xxx.xxx"
gateway_enable="YES"
ifconfig_wlan0="inet 192.168.1.1  netmask 255.255.255.0 ssid concordfamily mode 11n channel 1"
```


----------



## SirDice (Jan 31, 2012)

Remove the static routes. You still have one.

These are supposed to go in /boot/loader.conf:

```
accf_data_load="YES"
accf_http_load="YES"
```


----------



## xwwu (Jan 31, 2012)

Thanks, rc.conf looks much better. But dhcpd still can't be started as before. The problem is wlan0 can't be found by it.


----------



## SirDice (Jan 31, 2012)

Does the interface come up correctly? The DHCP daemon might be starting before the interface is completely initialized.


----------



## xwwu (Jan 31, 2012)

SirDice said:
			
		

> Does the interface come up correctly? The DHCP daemon might be starting before the interface is completely initialized.



The wireless card comes up correctly. And when booting, wlan0 appears before dhcpd. So what shall I do? Even cp the module into /boot/kernel/ is no good.


----------



## xwwu (Feb 1, 2012)

Problem sovled. Should be 11g instead of 11n, and all static routes should be erased. Thank you all.


----------



## SirDice (Feb 1, 2012)

Perfect. Do you also understand why you don't need static routes?


----------



## xwwu (Feb 1, 2012)

SirDice said:
			
		

> Perfect. Do you also understand why you don't need static routes?


 
Is it because of just two net interfaces, so route must be default?


----------



## SirDice (Feb 1, 2012)

No, it's because those networks are so-called 'directly connected'. Just have a look at your current routing table. You'll see the routes already exist.

If you have an interface in 192.168.1.0/24, that route will be automatically added. When a router routes packets it only looks at the destination address of the packet. When packet is destined for a 192.168.1.0/24 address it'll see it can reach that network on one of it's own interfaces. You only need to add routes if it can't figure out where the next hop would be.


----------



## xwwu (Feb 1, 2012)

```
netstat -r
Routing tables

Internet:
Destination Gateway Flags Refs Use Netif Expire
localhost link#8 UH 0 1366 lo0
192.168.0.0 link#1 U 0 265 re0
192.168.0.6 link#1 UHS 0 0 lo0
192.168.1.0 link#9 U 0 256 wlan0
asus link#9 UHS 0 0 lo0
```


----------

