# Static Routing



## drpaudel (Jun 1, 2010)

I m trying to establish a static routing between 2 Freebsd servers. But i m still unable to do though i studied detail freebsd handbook.

My Scenario is like this:
PC1 has bge0 with ip 192.168.1.1/24 which is connected with another freebsd server PC2 with cross cable. The other interface nge0 is connected to my laptop with ip 192.168.2.1/24 and my laptop static ip is 192.168.2.2 with default gateway 192.1168.2.1.  PC2 (next freebsd Server) is connected to PC1 whose IP bge0 is 192.168.1.2/24 and next interface of PC2 is nge0 192.168.3.1/24 and again connected with next laptop having ip 192.168.3.2 with default gateway 192.168.3.1 

How can I solve my problem.


----------



## Alt (Jun 1, 2010)

Seems you must set these routes
	
	



```
PC1# route add -net 192.168.3.0/24 192.168.1.2
PC2# route add -net 192.168.2.0/24 192.168.1.1
```


----------



## jalla (Jun 1, 2010)

And remember to enable forwarding

`sysctl net.inet.ip.forwarding=1`

(Or set gateway_enable="YES" in /etc/rc.conf)


----------



## drpaudel (Jun 1, 2010)

*Static Routing Problems*

Thank you very much for all replies. However I still could not connect the networks.Let me clearly write my internal networks as below:

1.my topology of routers is that I have 2 freeBSD machines supposed to be routers pc1 and pc2 respectively. Both pc1 and pc2 have 2 NIC cards.
2. Those 2 routers are connected with cross cable directly.
3. I have assigned IP for bge0 of pc1: 192.168.1.1 and 192.168.1.2 for bge0 of pc2
4. I have assigned IP for nge0 of pc1: 192.168.2.1 which is connected to notbook having IP of 192.168.2.2 in order to make small subnet.
5. I have assigned IP for nge0 of pc2: 192.168.3.1 which is connected to another notebook having IP of 192.168.3.2 in order to make another small subnet.
7. I want to send ping from notebook connected to pc1 to the notebook connected to pc2.  

Please look at the attached file at which I have completely done my settings. I would be very grateful should you send me the static routing information in this reply as per my configuration.


----------



## SirDice (Jun 1, 2010)

You seem to be lacking some basic TCP/IP networking skills.

http://www.redbooks.ibm.com/redbooks/pdfs/gg243376.pdf


----------



## lbol (Jun 1, 2010)

can you ping from PC1 to PC2? 
what does `# netstat -rn` give you on PC1 and PC2?
what is the output from `# ifconfig` on PC1 and PC2?


----------



## Alt (Jun 1, 2010)

This must finally help (rc.conf chunk)

```
hostname="pc1"
ifconfig_bge0="inet 192.168.1.1/24"
ifconfig_nge0="inet 192.168.2.1/24"
gateway_enable="YES"
static_routes="net3"
route_net3="-net 192.168.3.0/24 192.168.1.2"
```


```
hostname="pc2"
ifconfig_bge0="inet 192.168.1.2/24"
ifconfig_nge0="inet 192.168.3.1/24"
gateway_enable="YES"
static_routes="net2"
route_net2="-net 192.168.2.0/24 192.168.1.1"
```
And reboot both. If not help,
1. Check netmasks/gateways on notebook[1,2]
2. Write 5 ping results:
From pc1 to pc2 =)
From notebook[1,2] to pc[1,2]


----------



## drpaudel (Jun 2, 2010)

*Static Routing for FreeBSD works*

Dear Alt, Thank you very much.Your solution really works form me. Now, I can connect any PCs. Again thanks to the FreeBSD forum.


----------

