FreeBSD routing

Andrew P. infofarmer at gmail.com
Sat Oct 15 01:21:13 PDT 2005


On 10/15/05, Bob Hepple <bhepple at freeshell.org> wrote:
> Hello!
>
> I'm new to FreeBSD (5.3) and trying to make the transition from Linux. One
> thing that has me stumped is a routing question... it must be something
> really simple because I can do it all the time in Linux.
>
> I just want to add an arbitrary machine (eg. with IP 192.168.2.214) to my
> home network 192.168.254.0/24. Under Linux I just do a
>
>         route add -host 192.168.2.214 eth0
>
> and I can ping it.
>
> On FreeBSD I tried both
>
>         route add -host 192.168.2.214 192.168.254.245
>         route add -host 192.168.2.214 -interface rl0
>
> but I'm getting some kind of redirect loop. Apparently my use of the
> FreeBSD route command is wrong.
>
> BTW - I don't want to use DHCP for various reasons (mainly because I need
> to ssh to the new machine and therefore need to have a known IP address -
> but also because some of the machines I need to add don't support DHCP
> clients or else setting them up to do so is just too much).
>
> I haven't got round to natd and firewalling stuff yet and I won't try
> turning these on until I can at least ping the new box. For now, these
> features are not enabled in /etc/rc.conf.
>
> Just to eliminate the obvious - yes I booted Linux on this machine
> and tested it and it worked - so it's not a h/w problem.
>
> Here's the detail: I'm issuing the "route add" commands on "raita" and
> trying to reach "rasam":
>
>       internet
>         |
>       router
>         .192.168.0.1
>         .
>         .  wireless
>         .
>         .ath0/192.168.0.18
>       raita
>         |rl0/192.168.254.245
>         |
>     -------------------------- 10baseT
>                            |
>                            |
>                            |192.168.2.214
>                          rasam
>
> bash-2.05b# ifconfig -a
> rl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
>         options=8<VLAN_MTU>
>         inet 192.168.254.245 netmask 0xffffff00 broadcast 192.168.254.255
>         inet6 fe80::201:29ff:fe74:99c2%rl0 prefixlen 64 scopeid 0x1
>         ether 00:01:29:74:99:c2
>         media: Ethernet autoselect (none)
>         status: no carrier
> ath0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
>         inet 192.168.0.18 netmask 0xffffff00 broadcast 192.168.0.255
>         inet6 fe80::209:5bff:fee8:b9d2%ath0 prefixlen 64 scopeid 0x3
>         ether 00:09:5b:e8:b9:d2
>         media: IEEE 802.11 Wireless Ethernet autoselect (OFDM/54Mbps)
>         status: associated
>         ssid Baroona 1:Baroona
>         channel 6 authmode OPEN powersavemode OFF powersavesleep 100
>         rtsthreshold 2312 protmode CTS
>         wepmode MIXED weptxkey 1
>         wepkey 1:40-bit
>
> I tried two ways to add the route to rasam from raita:
>
> 1/ using the address for the interface:
>
> # netstat -rn
> Routing tables
>
> Internet:
> Destination        Gateway            Flags    Refs      Use  Netif Expire
> default            192.168.0.1        UGS         0       24   ath0
> 127.0.0.1          127.0.0.1          UH          0      139    lo0
> 192.168.0          link#3             UC          0        0   ath0
> 192.168.0.1        link#3             UHLW        1       22   ath0
> 192.168.254        link#1             UC          0        0    rl0
>
> bash-2.05b# route add -host 192.168.2.214 192.168.254.245
> add host 192.168.2.214: gateway 192.168.254.245
> bash-2.05b# netstat -rn
> Routing tables
>
> Internet:
> Destination        Gateway            Flags    Refs      Use  Netif Expire
> default            192.168.0.1        UGS         0      700   ath0
> 127.0.0.1          127.0.0.1          UH          0      139    lo0
> 192.168.0          link#3             UC          0        0   ath0
> 192.168.0.1        00:09:5b:ec:45:4a  UHLW        1       44   ath0    547
> 192.168.2.214      192.168.254.245    UGHS        0      448    rl0
> 192.168.254        link#1             UC          0        0    rl0
> 192.168.254.245    00:01:29:74:99:c2  UHLW        1      448    lo0
>
> bash-2.05b# ping rasam
> PING rasam.gc.eracom-tech.com (192.168.2.214): 56 data bytes
> 36 bytes from raita.finder.com.au (192.168.254.245): Redirect Host(New addr: 192.168.254.245)
> Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src      Dst
>  4  5  00 0054 00ba   0 0000  40  01 f6d2 192.168.254.245  192.168.2.214
> ...
>
> 2/ By using the interface name:
>
> bash-2.05b# netstat -rn
> Routing tables
>
> Internet:
> Destination        Gateway            Flags    Refs      Use  Netif Expire
> default            192.168.0.1        UGS         0      708   ath0
> 127.0.0.1          127.0.0.1          UH          0      139    lo0
> 192.168.0          link#3             UC          0        0   ath0
> 192.168.0.1        00:09:5b:ec:45:4a  UHLW        1       44   ath0    315
> 192.168.254        link#1             UC          0        0    rl0
> 192.168.254.245    00:01:29:74:99:c2  UHLW        0      448    lo0
>
> bash-2.05b# route add -host 192.168.2.214 -interface rl0
> add host 192.168.2.214: gateway rl0
> bash-2.05b# netstat -rn
> Routing tables
>
> Internet:
> Destination        Gateway            Flags    Refs      Use  Netif Expire
> default            192.168.0.1        UGS         0      708   ath0
> 127.0.0.1          127.0.0.1          UH          0      139    lo0
> 192.168.0          link#3             UC          0        0   ath0
> 192.168.0.1        00:09:5b:ec:45:4a  UHLW        1       44   ath0    286
> 192.168.2.214      00:01:29:74:99:c2  UHLS        0        0    rl0
> 192.168.254        link#1             UC          0        0    rl0
> 192.168.254.245    00:01:29:74:99:c2  UHLW        0      448    lo0
>
> bash-2.05b# ping rasam
> PING rasam.gc.eracom-tech.com (192.168.2.214): 56 data bytes
> 36 bytes from raita.finder.com.au (192.168.254.245): Redirect Host(New addr: 192
> .168.2.214)
> Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src      Dst
>  4  5  00 0054 063f   0 0000  40  01 f14d 192.168.254.245  192.168.2.214
>
> 36 bytes from raita.finder.com.au (192.168.254.245): Redirect Host(New addr: 192
> .168.2.214)
> Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src      Dst
>  4  5  00 0054 063f   0 0000  3f  01 f24d 192.168.254.245  192.168.2.214
>
> ... same story. Any idea what I'm doing wrong?
>
>
> Thanks
>
>
>
> Bob
>
> --
> Bob Hepple, Research & Development Group
> Eracom Technologies Australia Pty. Ltd.
> 28 Greg Chappell Drive, Burleigh Heads, Qld. 4220, Australia
> Tel.: +61 7 5593 4911               Fax.: +61 7 5593 4388
> mailto:bob.hepple at eracom-tech.com http://www.eracom-tech.com
> Public Key: http://bhepple.freeshell.org/public_keys.txt
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
>
>

I haven't tried this setup, and I'm too lazy to try it
now, but I would start with setting gateway_enable
in /etc/rc.conf, adding device bpf to kernel and
if that doesn't help, I'd try to add a static arp entry
(arp -s remote-IP remote-MAC).

Then of course, adding a 192.168.2.x/24 alias to
the interface would be a better (straighter)
solution, but I'd certainly like to find out how to
do it properly your way.


More information about the freebsd-questions mailing list