Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm running Devuan Linux in my PC.
I use dd-wrt router as DHCP server and internet gateway. The PC has static IP address, laptop gets a IP address when it's connected to the router.
It has two ethernet cards, one is onboard, the other one is a PCI card.
I only use the onboard ethernet device, eth0.
From time to time eth0 looses a static IP address I assigned. Then I have to manually assing the IP address using ifconfig and route to get network connection.
Last night it lost network connection again. 'ifconfig -a' showed eth0 without IP address.
I haven't spent time why this problem occurs seriously. Anyway I looked up /etc/network/interfaces file. I found "allow-hotplug eth1" line instead "allow-hotplug eth0".
I suspect "allow-hotplug eth1" never works till network cable is plugged in.
Code:
$ more interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# Primary network interface
# eth1 is wrong? (8/27/2016)
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
#IPv6 address
iface eth1 inet6 static
address 2001:db8::c0ca:1eaf
netmask 64
gateway 2001:db8::1ead:ed:beef
$ dmesg | grep -n eth
CODE]
422:[ 1.503295] alx 0000:02:00.0 eth0: Qualcomm Atheros AR816x/AR817x Ethernet [3e:a4:f0:6a:53:2a]
423:[ 1.503994] 8139too 0000:03:05.0 eth1: RealTek RTL8139 at 0xffffc90000c6ac00, 00:0e:e8:de:d2:e9, IRQ 20
594:[ 4.413447] 8139too 0000:03:05.0 rename3: renamed from eth1
599:[ 4.427551] systemd-udevd[415]: renamed network interface eth1 to rename3
700:[ 516.066783] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
701:[ 516.067542] alx 0000:02:00.0 eth0: NIC Up: 100 Mbps Full
702:[ 516.067772] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
776:[ 934.385429] alx 0000:02:00.0 eth0: NIC Up: 100 Mbps Full
[/CODE]
Should I remove "allow-hotplug eth0" from /etc/network/interfaces?
What would cause loosing the IP address given to eth0?
The longest uptime of the Devuan system was ninty some days. I use pm-hibernate instead turning off.
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541
Rep:
Looking at your static address, 192.168.1.100.
It's pretty typical that DHCP starts leasing ports at 192.168.1.100 and fixed IP would be from 192.168.1.2 through 192.168.1.99. That DHCP base address is settable in most routers.
Your gateway address would be 192.168.1.1 (which it is) and your fixed IP server would be something like 192.168.1.10 (or whatever floats your boat). Note that, if you have a Ethernet connected printer that you can simply set a fixed address, add it to your /etc/hosts file and anything connected to the LAN would be able to find it and print (fixed IP for printers is a good idea, less problems).
If by chance you've addressed your fixed IP server at 192.168.1.100, you may be colliding with DCHP?
My system uses a Linksys Cable/DSL Router w/4-port Switch, probably similar to yours. The fixed-IP address range is from 192.168.1.2 to 192.168.1.99 and DHCP is active for any non-fixed IP devices I plug in. Everything on my system is Ethernet-connected as every device has a fixed address; /etc/hosts looks like
Code:
cat /etc/hosts
#
# hosts This file describes a number of hostname-to-address
# mappings for the TCP/IP subsystem. It is mostly
# used at boot time, when no name servers are running.
# On small systems, this file can be used instead of a
# "named" name server. Just add the names, addresses
# and any aliases to this file...
#
# By the way, Arnt Gulbrandsen <agulbra@nvg.unit.no> says that 127.0.0.1
# should NEVER be named with the name of the machine. It causes problems
# for some (stupid) programs, irc and reputedly talk. :^)
#
# For loopbacking.
127.0.0.1 localhost
# For public and private OpenSRF comains
127.0.1.2 public.localhost public
127.0.1.3 private.localhost private
# Local servers
192.168.1.10 fubar.lan fubar
192.168.1.15 OfficeJet
192.168.1.20 snafu.lan snafu
192.168.1.30 pita pita.lan
192.168.1.2 hicl01.lan hicl01
# Public servers
75.126.162.205 www.linuxquestions.org linuxquestions.org
74.125.224.70 maps.google.com
74.125.224.111 maps.gstatic.com
# End of hosts.
Keep in mind that your router will give you a DHCP connection when you plug in pretty much anything unless the "thing" is using fixed IP (as in configuration of the device, like a printer configured for DHCP or for fixed IP or wireless). Bear in mind your fixed IP range, almost always below the DHCP range (which is usually 192.168.1.100).
I found why I used eth1 as default network interface device.
In 2013 I made a udevd rule file to name two ethernet cards in order.
eth0: Qualcomm Atheros AR8161 Gigabit Ethernet
eth1: RealTek RTL8139
One hour ago I changed the MAC address of AR8161 because ifconfig -a's value was different.
Code:
/etc/udev/rules.d
$ more 70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# lspci -nn | grep Eth
# Retrieve MAC address of each adapter
# udevadm info -a -p /sys/class/net/eth0 [eth1]
# ifconfig -a
# or
# ifconfig eth0 [eth1]
# Qualcomm Atheros AR8161 Gigabit Ethernet [1969:1091]
# Kernel module: alx
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="a2:71:b7:12:2d:c
0", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# Realtek Semiconductor Co., Ltd. RTL-8100/8101L/8139 PCI Fast Ethernet Adapter
# Kernel module: 8139too
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0e:e8:de:d2:e
9", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
After rebooting the system, the MAC address of AR8161 changed again.
[ 1.513275] alx 0000:02:00.0 eth1: Qualcomm Atheros AR816x/AR817x Ethernet [5e:05:c2:ee:4f:d5]
udev assigns eth0 to RealTek RTL8139 which has the same MAC address and AR8161 gets eth1. I don't know how it works though. Apparently to use AR8161 I did set up eth1 as default network interface device.
I'm running a liquorix kernel at the moment.
Code:
Linux dv1-station1 4.7.0-2.1-liquorix-amd64 #1 ZEN SMP PREEMPT liquorix 4.7-2 (2016-08-20) x86_64 GNU/Linux
I gonna install the latest kernel from Devuan and test behavior of MAC address of AR8161 beween bootings.
The solution is to create a proper rule file that identify network cards in the system.
I modified the rule file to give network interface names to each card.
$ more 70-persistent-net.rules
Code:
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# lspci -nn | grep Eth
# Retrieve MAC address of each adapter
# udevadm info -a -p /sys/class/net/eth0 [eth1]
# ifconfig -a
# or
# ifconfig eth0 [eth1]
# Qualcomm Atheros AR8161 Gigabit Ethernet [1969:1091]
# Kernel module: alx
KERNEL=="eth*", SUBSYSTEM=="net", DRIVER=="alx*", NAME="eth0"
# KERNEL=="eth*", SUBSYSTEM=="net", DRIVER=="8138too*", NAME="eth1"
# Realtek Semiconductor Co., Ltd. RTL-8100/8101L/8139 PCI Fast Ethernet Adapter
# Kernel module: 8139too
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0e:e8:de:d2:e9", ATTR{dev_id}==
"0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x10ec:0x8139 (8139too)
# SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0e:e8:de:d2:e9", ATTR{dev_id}
=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
And I added hwaddress ether line in /etc/network/interfaces file so that eth0 get a fixed MAC address.
$ more interfaces
Code:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto eth0
# The primary network interface
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
hwaddress ether 02:ec:0d:e1:fe:8a
The kernel module for AR8161 fails to get permanent MAC address of the ethernet card and it generates random MAC address for the ethernet card each time system starts. When it occurs udevd automatically changes network interface name without warning.
When I applied the same rule to Realtek ethernet card, it failed to recognize it, and creates new network device names.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.