Configure static IP on eth1
Solution 1
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
Solution 2
You forgot to activate your interface:
ifup eth1
Other things regarding your configuration:
- Add
auto eth1
so that you don't have to executeifup
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.
Related videos on Youtube
Daniel Gruszczyk
Currently working in UK as a Software Developer. In my spare time I am rock climbing and MTB racing.
Updated on September 18, 2022Comments
-
Daniel Gruszczyk over 1 year
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.-
schaiba about 7 yearsdid you restart the networking service after making the change(s) to
/etc/network/interfaces
? -
Zumo de Vidrio about 7 yearsaddress and gateway have the same value?
-
Daniel Gruszczyk about 7 yearsI did restart networking service, and I did down/up of the eth1 interface.
-
Daniel Gruszczyk about 7 years@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.
-
ilkkachu about 7 yearslooks 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?
-
-
Daniel Gruszczyk about 7 yearsI 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. -
xhienne about 7 yearsYour VPN needs a gateway. Maybe it's eth0's gateway? In that case, remove the gateway line for eth1. As for
ifup
, did you tryifdown --force eth1
beforeifup eth1
? Also, did you get any error message while ifup'ing ? Doesifconfig
showeth1
? Else, doesifconfig -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? -
Daniel Gruszczyk about 7 yearsThanks! I was missing the
auto eth1
line :)