LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 08-27-2016, 12:50 AM   #1
sparkybulbul
LQ Newbie
 
Registered: Nov 2015
Distribution: Devuan, Debian 8.2
Posts: 8

Rep: Reputation: Disabled
Does the network setting is wrong?


Hi,

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.

Running /etc/init.d/networking script wouldn't work.

Code:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.100  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::3ca4:f0ff:fe6a:532a  prefixlen 64  scopeid 0x20<link>
        ether 3e:a4:f0:6a:53:2a  txqueuelen 1000  (Ethernet)
        RX packets 152935  bytes 174995642 (166.8 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 124037  bytes 17996440 (17.1 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 10  bytes 772 (772.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10  bytes 772 (772.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

rename3: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 00:0e:e8:de:d2:e9  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
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.
 
Old 08-27-2016, 11:09 AM   #2
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
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.
And the configuration is
Code:
/sbin/ifconfig -a
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.10  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::210:18ff:fe8a:82c1  prefixlen 64  scopeid 0x20<link>
        ether 00:10:18:8a:82:c1  txqueuelen 1000  (Ethernet)
        RX packets 586079  bytes 741459877 (707.1 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 353015  bytes 33007099 (31.4 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 17  

eth1: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether b8:ac:6f:1c:ad:c5  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 21  memory 0xf7ae0000-f7b00000  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 258  bytes 54789 (53.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 258  bytes 54789 (53.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
The line above,
Code:
        inet 192.168.1.10  netmask 255.255.255.0  broadcast 192.168.1.255
is the fixed IP address of the server fubar.

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).

Hope this helps some.
 
Old 08-27-2016, 12:21 PM   #3
sparkybulbul
LQ Newbie
 
Registered: Nov 2015
Distribution: Devuan, Debian 8.2
Posts: 8

Original Poster
Rep: Reputation: Disabled
@tronayne

Thanks. I'll look into DHCP server setting.

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.
 
Old 08-29-2016, 10:35 AM   #4
sparkybulbul
LQ Newbie
 
Registered: Nov 2015
Distribution: Devuan, Debian 8.2
Posts: 8

Original Poster
Rep: Reputation: Disabled
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.
Code:
# KERNEL=="eth*", SUBSYSTEM=="net", DRIVER=="8138too*", NAME="eth1"
Code:
Aug 29 01:37:30 dv1-station1 kernel: [    1.586873] 8139too 0000:03:05.0 eth0: RealTek RTL8139 at 
0xffffc90000002c00, 00:0e:e8:de:d2:e9, IRQ 20
Aug 29 01:37:30 dv1-station1 kernel: [    1.587195] libata version 3.00 loaded.
Aug 29 01:37:30 dv1-station1 kernel: [    1.592921] alx 0000:02:00.0: Invalid permanent address pr
ogrammed, using random one
[    1.586873] 8139too 0000:03:05.0 eth0: RealTek RTL8139 at 0xffffc90000002c00, 00:0e:e8:de:d2:e9
, IRQ 20
[    1.595010] alx 0000:02:00.0 eth1: Qualcomm Atheros AR816x/AR817x Ethernet [7a:d0:74:ea:9c:ea]
[    4.061800] systemd-udevd[363]: renamed network interface eth1 to rename3
[    4.218486] systemd-udevd[360]: renamed network interface eth0 to eth2
[    4.238641] systemd-udevd[363]: renamed network interface eth1 to eth0

Last edited by sparkybulbul; 08-29-2016 at 10:37 AM.
 
Old 08-29-2016, 11:16 AM   #5
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
Glad you got it going (I'd never have thought about MAC addresses getting clobbered).

All is well that ends.
 
  


Reply

Tags
ifconfig


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting up mdadm raid filesystem wrong?? dragonfly-uk Linux - Newbie 4 05-06-2013 03:29 AM
[SOLVED] X uses the wrong Keyboard setting(s) tiuz Slackware 3 05-28-2010 04:40 PM
Network Manager 0.7 doesn't work or something wrong with my network card? G3N1USS Linux - Networking 0 12-06-2008 03:07 PM
mkdir in C++ setting wrong permissions fcdev Programming 4 01-13-2008 06:57 PM
Help!! DNS failed, what is wrong on my setting? explorer1979 Linux - Networking 3 04-02-2004 01:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 04:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration