0

I am trying to set static IP addresses on Network Interfaces, but the eth0 Interface takes the same IP address as thje wlan0 Interface.

This is the code

/etc/network/interfaces

auto lo
iface lo inet loopback

# DHCP Ethernet
# auto eth0
#iface eth0 inet dhcp
allow-hotplug eth0

# Static Ethernet
iface eth0 inet static
    broadcast 192.168.20.255 # broadcast address
    address 192.168.20.1    # here configure static IP address
    netmask 255.255.255.0   # here configure netmask of IP address
    gateway 192.168.20.1

allow-hotplug wlan0
auto wlan0 #
iface wlan0 inet static
    address 192.168.10.1
    netmask 255.255.255.0

ifconfig

eth0      Link encap:Ethernet  HWaddr b8:27:eb:c8:fd:39
      inet addr:192.168.10.1  Bcast:192.168.10.255  Mask:255.255.255.0
      inet6 addr: fe80::316a:b2b:c0bc:f83a/64 Scope:Link
      UP BROADCAST MULTICAST  MTU:1500  Metric:1
      RX packets:0 errors:0 dropped:0 overruns:0 frame:0
      TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback
      inet addr:127.0.0.1  Mask:255.0.0.0
      inet6 addr: ::1/128 Scope:Host
      UP LOOPBACK RUNNING  MTU:65536  Metric:1
      RX packets:336 errors:0 dropped:0 overruns:0 frame:0
      TX packets:336 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1
      RX bytes:27216 (26.5 KiB)  TX bytes:27216 (26.5 KiB)

wlan0     Link encap:Ethernet  HWaddr b8:27:eb:9d:a8:6c
      inet addr:192.168.10.1  Bcast:192.168.10.255  Mask:255.255.255.0
      inet6 addr: fe80::1512:1446:1044:c36e/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:2445 errors:0 dropped:13 overruns:0 frame:0
      TX packets:259 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:270903 (264.5 KiB)  TX bytes:48776 (47.6 KiB)

As you can see the eth0 interface is not getting the IP addres that is defined in the /etc/network/Interface configuration file.

The isc-dhcp-server is configured to work on all Interfaces:

authoritative;
subnet 192.168.10.0 netmask 255.255.255.0 {
    range 192.168.10.10 192.168.10.100;
    option domain-name-servers 8.8.8.8, 8.8.4.4;
    option routers 192.168.10.1;
    option broadcast-address 192.168.10.255;
}
subnet 192.168.20.0 netmask 255.255.255.0 {
    range 192.168.20.10 192.168.20.100;
    option domain-name-servers 8.8.8.8, 8.8.4.4;
    option broadcast-address 192.168.20.255;
    option routers 192.168.20.1;
}

Do You know what can be causing the problem? Thanks

1

I assume you are running Raspbian (you don't say).

Do You know what can be causing the problem

It might have something to do with the fact that you ignored the comment in the /etc/network/interfaces file

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

See How do I set up networking/WiFi/Static IP

PS I presume you copied the config from somewhere; please indicate where so we may be able to stop people using it.

PPS Your static settings make no sense, you are trying to allocate the same address to the Pi and the gateway.

  • Hello, I am running Rasbian, Jessie to be exact. I didnt copy it, I wrote it myself. I am still learning. Thank you for your help. – depecheSoul Sep 20 '16 at 11:04
1

You didn't mention in your post, but did you restart networking?

service networking restart

See if that refreshes.

1

You need to add auto eth0 above iface eth0 static command. I know this is an old post, but hopefully this will help someone in the future.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.