5

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)

8
  • 4
    route is deprecated. use ip route or routel instead, same for ifconfig (use ip 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
    – BatchyX
    Feb 1, 2013 at 20:25
  • Thanks BatchyX. I have just been using dhcp for so long that my command-fu has been a bit outdated. Feb 1, 2013 at 20:29
  • What does your network setup look like? Specially the net on eth1. ASCII art is fine.
    – vonbrand
    Feb 11, 2013 at 4:20
  • Could you resolve your route -n output into addresses only (you have the name adim.hhv3)
    – Lmwangi
    Jun 21, 2015 at 21:11
  • You can instruct dhclient to inject the relevant nameserver into your resolv.conf. On my machine, I have this: ❯❯❯ grep prepend /etc/dhcp/dhclient.conf prepend domain-name-servers 8.8.8.8;
    – Lmwangi
    Jun 21, 2015 at 21:15

1 Answer 1

1

How do the hosts on the the 192.168.0.x network get their network configuration? If they expect to receive it via DHCP, you will probably need to run a DHCP server on eth1 (being very careful not to offer it on eth0!). If the devices don't have addresses, you won't be able to route to them.

On my home router I run the ISC dhcpd on eth0 whilst acting as a DHCP client on ppp0. Relevant bits of configuration in /etc/dhcpd.conf include:

# Don't attempt dynDNS updates
ddns-update-style none;

# option definitions common to all supported networks...
option domain-name "mydomain";
option domain-name-servers 192.168.0.1;  # This machine

default-lease-time 86400; # 1 day
max-lease-time 864000;    # 10 days


  group {
    # PXE-boot clients
    filename "/pxelinux.0";
    next-server 192.168.0.1;

    host myhost1 {
      hardware ethernet 00:30:18:a5:6b:20;
      fixed-address 192.168.0.66;
      option root-path "192.168.0.1:/export/client/myhost1";
    }
  }

  # Dynamically-leased addresses for visitors
  subnet 192.168.0.0 netmask 255.255.255.0 {
    authoritative;  
    range 192.168.0.128 192.168.0.254;
    option broadcast-address 192.168.0.255;
    option routers 192.168.0.1;
  }

I previously ran dnsmasq successfully on eth0 (I still do, but now only for DNS and not for DHCP). Here's the old, commented-out snippets from /etc/dnsmasq.d/dhcp.conf:

#interface=eth0

# read-ethers

# dhcp-range=192.168.0.128,192.168.0.254

# dhcp-host=00:30:18:a5:6b:20,myhost1,192.168.0.66,static

# dhcp-option-force=208,f1:00:74:7e

# dhcp-boot=pxelinux.0

# #enable-tftp
# tftp-root=/var/lib/tftpboot

# log-dhcp

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .