I have added a secound nic in a debian box. That nic is ment for doing some test stuff, so those devices connected should just be able to access the debian box or be accessed from it.
To set up the nic, I have added to /etc/network/interfaces
iface eth1 inet static
address 192.168.0.2
netmask 255.255.255.0
broadcast 192.168.0.255
network 192.168.0.0
Those values shows up when I do an ifconfig, and route shows:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default adim.hhv3 0.0.0.0 UG 0 0 0 eth0
192.168.0.0 * 255.255.255.0 U 0 0 0 eth1
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
SO it seems to me as if everything is set up correctly, but when I try to access any of the devices on the 192.168.0.x network, I just get a "no route to host" error. Have I forgotten or overlooked something? (presently I cannot test the other way around. The nic leds are indicating that there is a link)
Things get weirder. I have set up an old wireless router that acts as a dhcp server on the eth1 network. Then eth1 works just as intended - but if I try to set it manually, it does not work. When setting manually, I just use the above mentioned interfaces file.
Set from dhcp:
root@sorbus:~# ip addr (removed loopback and eth0)
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:11:95:84:6b:6c brd ff:ff:ff:ff:ff:ff
inet 192.168.0.142/24 brd 192.168.0.255 scope global eth1
inet6 fe80::211:95ff:fe84:6b6c/64 scope link
valid_lft forever preferred_lft forever
root@sorbus:~# ip route
default via 192.168.1.1 dev eth0 proto static
192.168.0.0/24 dev eth1 proto kernel scope link src 192.168.0.142
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.23
And now it seems to work also for the manual setup.... :-/ Good that it works but it would be nice to know why...
(I cannot use dhcp on the 192.168.0 since it messes up my resolv.conf - at least I have not seen any way of stopping it from doing it)
route
is deprecated. useip route
orroutel
instead, same forifconfig
(useip addr
instead).ip route
has a nice option:ip route get 192.168.0.42
will tell you what route the kernel will use to contact 192.168.0.42