Route not working to second interface

  • Thread starter Deleted member 9563
  • Start date
D

Deleted member 9563

Guest
I have two network cards in one computer. I can ping the second one from its host, but not from other machines on the same subnet. (eg. 192.168.1.101) Here are the relevant lines in rc.conf.

Code:
ifconfig_em0=" inet 192.168.1.103 netmask 255.255.255.0"
defaultrouter="192.168.1.1"
ifconfig_rl0="inet 192.168.1.141 netmask 255.255.255.0"
gateway_enable="YES"
static_routes="xer"
route_xer="-host 192.168.1.0/24 192.168.1.103"

I have also tried -interface and -net arguments.
 
You have conflicting subnets on the interfaces, both are in the same 192.168.1.0/24 subnet. That is not going to work with FreeBSD's routing that is very strict about such conflicts. Change the second interface to this and lose the extra routes.

Code:
ifconfig_rl0="inet 192.168.1.141 netmask 255.255.255.255"

This all assuming that both interfaces are connected to the same LAN.
 
Thanks @kpa, that's informative. Unfortunately I can't get it to work. Perhaps I'm not giving enough information. I may also be trying to do something which is too awkward, and in the wrong way.

I put the second card into the 192.168.103 machine in order to plug in a printer which I wished to access from other computers which are also plugged into the 192.168.1.1 gateway router. I gave the second card (in the .103 box) the IP 192.168.1.141, used a crossover cable, and gave the printer the same .141 address as the second card.

Part of the reason I wanted to do it this way was to keep the .103 and another one configured and up-to-date with roughly the same installation of FreeBSD. Another reason is that the .103 is too far from the router to run a second cable. Perhaps I should just use a switch and not bother with this idea.

Assuming that this is not a bad idea, how would I do it?
 
Last edited by a moderator:
Not a network engineer, but why give both devices the same IP? Could you not give the printer its own IP and set static routes on 103 and the other hosts?

Code:
#route add ip.of.printer.device 192.168.1.141

I suppose if you have lots of other hosts on the LAN that might not be practical ...
 
Thanks dalecosp. I couldn't get that to work either. I used the same IP on the printer and its associated interface, together with a crossover cable, since that's what seems to be suggested in several places on the net.

I may revisit this concept in the future when I have more skills. In any case, I just now put in a switch, and it looks like I can access the printer from anywhere. I guess I should have done that in the first place. :)
 
Every "node" in a network must have a unique IP address, you can not cheat that anyway. Also you can not use addresses from the same subnet on multiple interfaces that are not connected to the same physical network.
 
I keep a list of all IP addreses for my computers and devices which I prefer to DHCP. I read that a printer should have the same IP as it's external interface and be connected with a crossover cable. I guess that's wrong. In any case, I tried changing the interface IP so that the two were different.

kpa said:
Every "node" in a network must have a unique IP address, you can not cheat that anyway. Also you can not use addresses from the same subnet on multiple interfaces that are not connected to the same physical network.

I think this is where my understanding falters. I thought what I was doing was on the same physical network, even when using port forwarding through the 192.168.1.103 machine. I guess that's wrong too. :)

In any case, I've given up on what is obviously an over complicated idea, although I'm sure it can be done and that you guys would help me. :) The switch is probably the simpler and more easily manageable solution - I can also use the extra ports in the future.
 
This looks like a fairly straightforward tutorial about routing. You should definitely read it. Getting to grips with TCP/IP and routing may look a little daunting at first but it's actually really easy once you know a few basic things.

http://www.sangoma.com/tutorials/tcp_ip/
 
If the second card was just for an extra port, it's not necessary to mess with routes at all. Give the second card a new network that does not overlap the old one, say 192.168.2.1/24:
Code:
ifconfig_rl0="inet 192.168.2.1/24"

No additional routes are needed, a route for that network will be added automatically.

Connect the printer to that card. Crossover cables are not needed on gigabit cards, which have auto-crossover.

Finally, give the printer a unique address in the new network. For example, 192.168.2.250.

The FreeBSD system will be able to talk to the printer. For other computers to be able to reach the printer, the FreeBSD system needs to be a router, with gateway_enable="YES" in /etc/rc.conf.
 
Thanks @wblock@. I see I wasn't all that far off. Like I said, I'm using a switch now, and have a gigabit switch on the way. However, I just might give your suggestion a try - especially since I now have this brand new printer working and so have less variables in the mix.

I don't have any gigabit cards (my stock goes back to the early 80's and is a bit thin on the newer stuff). :e So, the DFE-530TX+ probably does need the crossover cable. Anyway, you got me figured out; the second card was just for an extra port.

BTW: I got the printer working by using your instructions. :)
 
Last edited by a moderator:
Back
Top