2

I want to configure my eth1 interface to have a static IP, even if the cable is not plugged in. Is that at all doable?
I need that as I want to eventually configure a DHCP server (isc-dhcp-server) to give an IP address to a device that will be connected to my machine via this interface. The device, however might not be plugged in all the time. And it seems like DHCP server will refuse to start if that interface doesn't have an IP/subnet. (please correct me if I am wrong).
My /etc/network/interfaces has the following entry for eth1:

iface eth1 inet static
address 192.168.20.1
netmask 255.255.255.0
gateway 192.168.20.1

Still when running ifconfig the eth1 doesn't have an IP assigned.
I was always completely ignorant in terms of networking etc, so I might be missing something very obvious.
Any help appreciated. Thanks.

5
  • 2
    did you restart the networking service after making the change(s) to /etc/network/interfaces ?
    – schaiba
    Mar 21, 2017 at 14:38
  • 1
    address and gateway have the same value? Mar 21, 2017 at 14:38
  • I did restart networking service, and I did down/up of the eth1 interface. Mar 21, 2017 at 14:44
  • @ZumodeVidrio I took that from here. I am trying to do a very similar thing, except my "host B" would not have a static IP, but rather one assigned by DHCP server. Mar 21, 2017 at 14:52
  • looks like a valid configuration for Debian. Though you didn't say what distribution you have. It doesn't happen to run Network Manager or something similar which would want to control everything? What happens if you remote that odd gateway assignment?
    – ilkkachu
    Mar 21, 2017 at 15:23

2 Answers 2

2

You have to write before this:

 auto eth1
 iface eth1 inet static
     address 192.168.20.1
     netmask 255.255.255.0
     gateway 192.168.20.1
1
  • Thanks! I was missing the auto eth1 line :) Apr 10, 2017 at 8:17
1

You forgot to activate your interface:

ifup eth1

Other things regarding your configuration:

  • Add auto eth1 so that you don't have to execute ifup manually
  • As noticed by Zumo de Vidrio, your gateway address is useless, if not wrong. Put in the IP address of the box that connects your Raspberry-Pi to the Internet.
2
  • I did restart eth1 (ifconfig eth1 down/up). Also, I don't think that I want to set the gateway as the box that connects me to the internet. Eventually I will aim to redirect all traffic from eth1 to tun0 (OpenVPN connection that I have already running). From examples around internet I saw this done using iptables. Mar 21, 2017 at 14:56
  • Your VPN needs a gateway. Maybe it's eth0's gateway? In that case, remove the gateway line for eth1. As for ifup, did you try ifdown --force eth1 before ifup eth1? Also, did you get any error message while ifup'ing ? Does ifconfig show eth1? Else, does ifconfig -a show your IP? Finally, if could help if you show us your whole /etc/network/interfaces config file, can you update your question please?
    – xhienne
    Mar 21, 2017 at 15:25

You must log in to answer this question.

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