• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Need help with static routes

Khaine

Member

Thanks: 4
Messages: 52

#1
I am trying to set a router up in front of my FreeBSD gateway. I've configured the router to have DHCP on the WAN interface, and a static ip on the LAN interface. I've configured the same on my FreeBSD gateway:


Internet ----> DHCP [Router] 10.0.1.1 --> 10.0.1.2 [FreeBSD gateway] -> DHCP -> [Clients]

I have set up a static route on the Router to allow it to communicate with clients. With this set up I can ping the clients and the internet from the router. From the FreeBSD gateway and the clients I can ping the Router but not the internet:


FreeBSD:~ % ping 10.0.1.1
PING 10.0.1.1 (10.0.1.1): 56 data bytes
64 bytes from 10.0.1.1: icmp_seq=0 ttl=64 time=0.412 ms
64 bytes from 10.0.1.1: icmp_seq=1 ttl=64 time=0.352 ms
64 bytes from 10.0.1.1: icmp_seq=2 ttl=64 time=0.374 ms

FreeBSD:~ % traceroute 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 64 hops max, 40 byte packets
1 10.0.1.1 (10.0.1.1) 0.513 ms 0.404 ms 0.348 ms
2 * * *

Client $ traceroute 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 64 hops max, 52 byte packets
1 freebsd (10.0.0.1) 0.489 ms 0.258 ms 0.227 ms
2 10.0.1.1 (10.0.1.1) 0.585 ms 0.578 ms 0.491 ms
3 * *^C



The routing table on the router is as follows:

$ netstat -ar
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
default 124-149-191-1.d 0.0.0.0 UG 0 0 0 eth0
10.0.0.0 10.0.1.2 255.255.255.0 UG 0 0 0 eth1
10.0.1.0 * 255.255.255.0 U 0 0 0 eth1
124.149.191.0 * 255.255.255.0 U 0 0 0 eth0
loopback * 255.0.0.0 U 0 0 0 lo


I'm not sure why my clients and the FreeBSD gateway cannot access the internet. Any help would be greatly appreciated
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 6,125
Messages: 27,000

#2
I suggest to always use netstat -rn to view the routing table. The -n will stop it trying to reverse resolve IP addresses. For routing tables it's easier to look at the IP addresses instead of hostnames.

You have two networks on eth1, running two different subnets on the same broadcast domain is possible but not recommended, you should split up 10.0.0.0/24 and 10.0.1.0/24 to different interfaces. Your clients need a gateway in the 10.0.1.0/24 network, 10.0.0.1 is outside their subnet and cannot be reached directly.
 

Khaine

Member

Thanks: 4
Messages: 52

#3
The LAN interface on my FreeBSD gateway has the IP of 10.0.0.1

Internet ----> DHCP [Router] 10.0.1.1 --> 10.0.1.2 [FreeBSD gateway (NAT)] -> 10.0.0.1 -> [Clients]

The intent of my static route is to allow the router to have access to some of the clients. But if I understand you, the route should actually be on the Gateway, correct?

Thanks for your help.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 6,125
Messages: 27,000

#4
You're trying to mix two different subnets on the same wire. That's bound to cause problems because it's utterly confusing.

Clients in the 10.0.0.0/24 network have 10.0.0.1 as their gateway. Clients in 10.0.1.0/24 have 10.0.1.1 as gateway. A default gateway must always be in the same network as the host is. That's a basic routing requirement.
 

Khaine

Member

Thanks: 4
Messages: 52

#5
Ok,

What I am trying to achieve is that clients in the 10.0.0.0/24 network can access the internet (ultimately through 10.0.1.1) and that 10.0.1.1 can access a management server in 10.0.0.0/24. Is that achivable? If not, it sounds like it would be better to flip it and have the FreeBSD gateway as the ultimate external gateway, and put the router on the inside of the gateway.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 6,125
Messages: 27,000

#6
What I am trying to achieve is that clients in the 10.0.0.0/24 network can access the internet (ultimately through 10.0.1.1) and that 10.0.1.1 can access a management server in 10.0.0.0/24. Is that achivable?
Sure, if the routing is set up correctly this will work without problems. But if you want to separate 10.0.0.0/24 and 10.0.1.0/24 it'll be better (easier to understand) if you used two interfaces for it. So, in your case, the FreeBSD gateway machine will have 3 interfaces, one attached to the uplink router; 124.x.x.x/??, one for 10.0.0.0/24 and one for 10.0.1.0/24.
 

Khaine

Member

Thanks: 4
Messages: 52

#7
My FreeBSD gateway only has two physical interfaces. This is why I created the static route on the router. I thought that it was the correct way to describe a route to the clients for the router.

How can I create another virtual interface on the FreeBSD gateway to achieve the best way to set this up?
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 6,125
Messages: 27,000

#8
With only one physical interface you typically solve this by using vlan(4)s. But this does require the switch to be a managed switched and it needs to have VLAN support.

It can be done with just one interface, it just makes things a little more complex and a lot more error-prone.
 

Khaine

Member

Thanks: 4
Messages: 52

#9
It sounds like it would be easier to switch the gateway and the router so that I didn't need to create a vlan
 

Khaine

Member

Thanks: 4
Messages: 52

#10
I switched my setup around to avoid needing to create a VLAN. My setup is now:

Internet ----> DHCP [FreeBSD gateway (NAT)] 10.0.1.1 --> 10.0.1.2 [Router] -> 10.0.0.1 -> [Clients]

The routing tables are now:


FreeBSD:~ % netstat -rn
Routing tables

Internet:
Destination Gateway Flags Netif Expire
default 124.171.8.1 UGS em1
10.0.1.0/24 link#1 U em0
10.0.1.1 link#1 UHS lo0
124.171.8.0/22 link#2 U em1
124.171.10.59 link#2 UHS lo0
127.0.0.1 link#3 UH lo0



Router:~$ netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 10.0.1.1 0.0.0.0 UG 0 0 0 eth0
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
10.0.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo


However, with this set up my clients are still unable to access the internet. What have I done wrong?
 
Top