I have an embedded system that requires me to pull a MAC address out of flash and pass it to the Ethernet interface at the time it is brought up. Traditionally I have modified the call to ifconfig in an init script to just pass the MAC pulled out of flash as the hw ether parameter.
The system I am working on uses connman to handle the network connection. The embedded system will always have a single Ethernet connection with a single matching MAC address in a custom format in flash. connman is used as when the interface is available changes, so having a dynamic system for handling bringing the interface up and down and configuring it is helpful.
Is it possible to pass the MAC to connman to use in a similar way to what I have done before with ifconfig and, if so, how?
Alternatively is it possible to pass the MAC as a boot parameter to the kernel so that connman never has to know about this? I can pull the MAC out of flash in U-Boot but the Ethernet device is not available to U-Boot.
Alternatively is it possible to pass the MAC as a boot parameter to the kernel so that connman never has to know about this?
Yes, you can use U-Boot's ethaddr environment variable to do exactly that.
Check out U-Boot Environment Variables for documentation on the variable.
Relevant documentation snippet:
ethaddr: Ethernet MAC address for first/only ethernet interface (= eth0 in Linux).
This variable can be set only once (usually during manufacturing of the board). U-Boot refuses to delete or overwrite this variable once it has been set.
It may be as simple as running the following commands to set the environment variable and save it (substituting your MAC address of course):
setenv ethaddr 11:22:33:44:55:66
saveenv
If ethaddr isn't already used in your U-Boot boot line then you'll need to do more than just the above. For an example of how to configure this on a system, check out How to set a fixed MAC address in a LeopardBoard DM36x.
Here's the boot command utilizing ethaddr that the above site ends up with:
setenv bootcmd 'setenv bootargs \${bootargs} davinci_emac.ethaddr=\${ethaddr}; nboot 0x82000000 0 \${kerneloffset}'
Related
I'm attempting to get kernel debugging to work during boot. I've followed all the steps to install it (how to use kgdb over ethernet(kgdboe)?) and can connect fine when I insmod after loading, but if I add this
BOOT_IMAGE=/vmlinuz-4.0.0-rc7+ root=UUID=<my_root> ro drm.debug=0x04 kgdbwait kgdboe=#<src_ip>/eth1,#<target_ip>/ vt.handoff=7
to the kernel boot line, I don't see the module loaded, and it doesn't kgdbwait.
When I look at my kern.log, I see the following:
kgdboe: eth0 does not have a in_ifaddr struct associated. Cannot get default IP address.
I have both eth0 and eth1 by the way, but only eth1 is connected.
Any suggestions? Is it just that the pcie network card isn't loaded until after boot and it's causing me issues?
Also, why would I need to specify the source or target ip addresses? Is there any way to have kgdboe accept all ip addresses, even when trying to load it at boot?
Thanks
Yes, for early kernel debug kgdboe does not really work. There are several issues, some easy to solve, some not solveable. You can hard link the required modules rather than demand load them to solve the easy issue. But the core problem is that the kgdb early wait will pause all worker threads, and nearly all of the Ethernet PCIe card drivers require worker threads, or else require IRQs. Even on the polled Ethernet driver support (very limited), the IRQ's can be preempted (or illegally hold locks), and prevent the polled Ethernet driver from functioning. As a result early kernel debug does not function with kgdboe reliably, and with some Ethernet drivers, at all. (e.g. kgdbwait on the GRUB2 boot line.) There has been occasional talk about hacking up various Ethernet driver sources to attempt to provide kgdboe support over a special purpose Ethernet driver, but none that I know of that is distributed. You are still best off with using a serial port, and for full functionality, a serial console, which can be multiplexed onto a single serial port if need be with kgdboc (agent-proxy). If true remote access is required, then remote into the debugging system that initiates the serial connection.
You can also use the USB port, but requires a specific USB<->serial USB dongle that is no longer sold. (Ajays Blue dongle). These were discontinued about 6 months ago, and there is no replacement yet. (It was a Windows debugging device adapted to Linux, and Windows has moved on to native USB3.0 debugging features, and Linux has yet to catch up to that.) So, unless you have the needed USB converter, or have another source, or have an alternative adapter, you are out of luck on USB2.0.
Serial is still your best option, sadly, even in 2016.
See: http://kdbg.wiki.kernel.org
i am building custom operating system with motherboard(MSI Gaming motherboard) and two e1000e driver support NIC cards.i want to use ports which is in nic card instead of onboard.
for disabling onboard port,i tried with 70-persistance-rule.but it didn't worked for me.
thanks in advance.
Firstly, you need to determine what the driver is. To do this, open a terminal and run the command:
lshw -C network|more
This will display a load of information about your network device/s. Somewhere in the output you will see module=drivername in my case the Intel onboard NIC driver was module=e1000e
Once you have identified the driver name open /etc/modprobe.d/blacklist.conf
At the bottom of the file add the following line (this uses my driver module (e1000e) as an example, just replace it with the module name of yours)
blacklist e1000e
Reboot for the blacklist to take effect. From now on whenever Linux boots, the kernel will not load the driver for the NIC.
I have a Dell laptop running the following version of RedHat Linux:
2.6.18-53.el5 #1 SMP Wed Oct 10 16:34:02 EDT 2007 i686 i686 i386 GNU/Linux
It has an Ethernet-over-USB connection to a device under test (DUT). This interface to the DUT is usually configured as follows:
IP address: 104.4.40.2
Netmask: 255.255.255.0
Default gateway: 104.4.40.1
The default gateway points to the DUT.
Occasionally, I need to change the IP address / default gateway to 104.4.20.2 and 104.4.20.1, respectively. (The netmask remains 255.255.255.0).
I need to make this change when I load a new configuration onto the DUT that changes its IP address. (This configuration loading is done over a second interface that is unrelated to the interface I'm discussing here.)
When I make the corresponding change to the Linux box's network configuration using the GUI, everything works fine. But I often work remotely by shelling in via ssh. So, all I have available in that case is a Bash shell.
I've used command "ifconfig" (to set the IP address and netmask) and command "route" (to install the default gateway forwarding entry) to reconfigure the interface, and I then used "iconfig" to bring the interface down and back up to try to get the changes to "take".
When I check the interface settings with "ifconfig", they looks right. When I check the forwarding table with "route", everything looks good (including the default gateway). Yet, when I try to ping the DUT, I get no reponse. If I configure the interface yet again using the GUI, I can then ping the DUT.
I am clearly doing something wrong. Could someone please kindly show me the Bash shell command line commands I need to issue to change the IP address and default gateway of interface "eth1"?
Thank you in advance!
If I've got you right, you need these two simple commands:
vim /etc/sysconfig/network-scripts/ifcfg-eth1 //modify the configuration
service network restart
Also you can write a primitive bash/perl/python wrapper for your routines...
This answer may be useful for you too.
I want to build a MAC address spoofer that spits out a randomize mac address everytime my computer boots up. My question is how and from where do all my computer programs in linux pull up my MAC address. I know that my wi-fi network driver is responsible for telling my network card what to send, but from where does that driver get my MAC address? I also know that a MAC address is called a hardware address, however since it is possible to spoof MAC addresses, then it must only mean that the MAC address on my network card doesn't have to be used when sending information. I would like to know how this can be done as well.
Also when randomizing my MAC address this ought to work with all other programs such as my web-browser and whatever else that I use, which shouldn't be a problem since thats really an application layer ... not link layer
Thanks
The MAC address is usually stored in some kind of EEPROM on the network card. This address is read during initialization by the network adapter driver and used by the MAC layer when assembling/sending netowrk packets.
The MAC address used can be changed on the command line using "ifconfig" via the "hw" option:
hw class address
Set the hardware address of this interface, if the device driver
supports this operation. The keyword must be followed by the
name of the hardware class and the printable ASCII equivalent of
the hardware address. Hardware classes currently supported
include ether (Ethernet), ax25 (AMPR AX.25), ARCnet and netrom
(AMPR NET/ROM).
ifconfig essentially uses the SIOCSIFHWADDR ioctl (see http://linux.die.net/man/7/netdevice) to set the MAC address.
In some cases it might even be possible to change the MAC address stored on the network adapter itself, see http://linux.die.net/man/8/ethtool - but I wouldn't recommend doing that.
The only thing that cares about your MAC address is the NIC itself. There should be no programs that use the MAC address (including browsers). Since MAC addresses are used on the physical layer -- that's the only thing that will read your MAC (such as routers, switches, etc).
To set the MAC address of your NIC you can use the ifconfig command: ifconfig eth0 hw ether ##:##:##:##:##:## (you might have to take your network down first, set it, and then bring it up. IE: ifconfig eth0 down; ifconfig eth0 hw ether ##:##:##:##:##:#; ifconfig eth0 up)
With VMWare Server running under Linux (Debain), I would like to have the following setup:
1st: NIC being used by many of the
images running under VMWare, as well
as being used by the Linux OS
2nd: NIC being used by only 1 image and to be unused by the Linux OS (as its part of a DMZ)
Although the second NIC won't be used by Linux, it is certainly recognised as a NIC (e.g. eth1).
Is this possible under VMWare Server, and if so, is it as simple as not binding eth1 under Linux and then bridging it to the image under VMWare Server?
I believe you can set the desired solution up by rerunning the vmware configuration script. And doing a custom network setup, so that both NIC's are mapped to your vmware instance. I would recommend making eth0 the 2nd NIC since it will be easier for Linux to use by default. Then make eth1 the 1st NIC.