systemd network service does not work? - networking

Today, I install ubuntu 16.04 in my machine.
When I boot the system, I can not get the IP address from DHCP server.
The network interface is renamed to enp2s0 from eth0.
I only get the IP address after run command:
$ sudo ethtool -s enp2s0 autoneg off speed 100
I try to add this command in init script (/etc/rc.local) but it does not work after I reboot system.
So, from now, when my machine is booted, I always need to add the above command mannually to get IP address.
Could anyone help me to solve this problem?
Thanks in advance.
Best Regards,

Since you're using ubuntu, use command line and execute the following:
$ sudo crontab -e
and add your script that you want to execute upon restarts by adding this at the end:
#reboot ethtool -s enp2s0 autoneg off speed 100
Hope this helps.

systemd considers both "rc.local" and "crontabs" to be "legacy". It has replacements for both. However, Ubuntu 16.04 supports both concepts.
I think your issue is that now rc.local is run before the network is fully online, causing your command to fail.
Look at /lib/systemd/system/rc.local.service to see how systemd is running your rc.local file. In particular note that the line After=network.target.
Try creating this file:
/etc/systemd/systemd/rc.local.service.d/10-wait-for-network.conf
Add these lines to it:
[Unit]
After=network-online.target
Then reboot and see if that works for you.
References:
Force services to wait for the network to be configured
Using systemd Drop-In units
Also, in the future SO is not the best place for systemd questions. Consider http://askubuntu.com for Ubuntu question instead.
I'll also add that the behavior change you found might be considered a bug in how Ubuntu emulates rc.local support with systemd. If the proposed fix works, perhaps Ubuntu shoudl change the rc.local replacement to load after network-online instead of network.

Related

Network manager flickering between device not managed, and no network devices available

Used sudo apt-get upgrade
After reloading the machine, when I hover over the network icon in the top right it flickers between device not managed, and no network devices available.
I changed /etc/NetworkManager/NetworkManager.conf to flip managed to true.
Running ip link will sometimes display wlan0 and will sometimes not, but when it does display wlan0 the number before it increases incrementally.
I can't copy the output due to having no connection on the machine, but after qdisc it has noop state down.
For ifconfig i get the output: wlan0: error fetching interface information: Device not found, and sometimes it does not find the device at all.
A similar output for iwconfig sometimes it will give information about wlan0 and sometimes it will state No such device
tail syslog gives iwlwifi Firmware not running - cannot dump error
ip link set wlan0 up returns either cannot find device or RTNETLINK answers: Input/output error
So first, looking into the dump error lead to this forum:
https://bbs.archlinux.org/viewtopic.php?id=247575
From here it lead to this bug forum: https://bugs.archlinux.org/task/63117
This says to downgrade the version of iwlwifi
Unfortunately, I am not able to downgrade and have it work, maybe someone else could explain that, but another workaround is to reboot, and at the grub menu go onto advanced and pick the previous kernel.
https://www.linuxuprising.com/2018/10/how-to-keep-package-from-updating-in.html
https://www.tecmint.com/remove-old-kernel-in-debian-and-ubuntu/
Now type sudo apt-mark hold firmware-iwlwifi
sudo apt-get upgrade will now say there is no files to update
uname -sr to get the current kernel (the one where the wifi works)
dpkg -l | grep linux-image | awk '{print$2}'
sudo apt remove --purge linux-image
sudo update-grub2
sudo reboot
Now when you boot you should boot into the previous saved kernel
sudo apt-mark showhold -to make sure iwlwifi is still held
sudo apt-get update
sudo apt upgrade
Now when you reboot you should have the updates without the new iwlwifi which has the bug
If I am wrong please correct me, this came from my own personal issue with the upgrade and this is how I fixed it for me, so if there is a much easier way please let those that come across this know

Arduino Tools > Serial Port greyed out

I am running Debian 7 (Linux Crunchbang) and wanted to use The Arduino IDE to program my Arduino UNO. To do that I installed the package arduino. When I started the Arduino I was asked to add my user to the dialout group. So I did with sudo usermod -a -G dialout <my-username>.
However when I start the Arduino IDE using arduino in the commandline the IDE opens but I am not able to load my program to the Arduino. The error message is "Serial port COM1 not found. Did you select the right one from the Tools > Serial Port menu?" And when I went to select the Serial Port, the option "Tools > Serial Port" is greyed out.
I thought it is because I did not grant read and write permissions on my usb port (ttyACM0). So I did sudo chmod a+rw /dev/ttyACM0 but the option is still greyed out.
chdmod works for my under debian (proxmox):
# chmod a+rw /dev/ttyACM0
For installing arduino IDE:
# apt-get install arduino arduino-core arduino-mk
Add the user to dialout group:
# gpasswd -a user dialout
Restart Linux.
Try with the File > Examples > 01.Basic > Blink, change the 2 delays to delay(60) and click the upload button for testing on arduino, led must blink faster. ;)
sudo arduino is the only way I get the Arduino IDE working (serial port and upload) on ubuntu 12.04 (64)
Indeed the serial port to use is /dev/ttyACM0 in my case too.
The other two (ttyS4 and ttyS0) gave an error when trying to upload to Uno.
Have fun
Try Disconnecting the usb and plugging it back in. Its only grayed out because the ide cannot find any com ports that the uno has been plugged into.
another solution is to try all the com ports and see which one works.
finally if all fails try restarting your computer.
Close all instances of the arduino IDE
open ~/.arduino/preferences.txt and look for the line:
serial.port=<not your port>
and change it to your port:
serial.port=/dev/ttyACM0
you may have to log out for it to take effect
open $arduinoHome/arduino in text editor and modify last string:
java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel processing.app.Base "$#"
to
java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -Dgnu.io.rxtx.SerialPorts="/dev/ttyACMN" processing.app.Base "$#"
(set property gnu.io.rxtx.SerialPorts to /dev/ttyACMN,where ttyACMN is name of serial port which you use)
it may temporary fix bug in rxtx library. helped me to upload sketch with arduino1.0.5 IDE.
Maybe would helpful for someone.
In my case this turned out to be a bad USB hub.
The 'lsusb' command can be used to display all recognized devices. If the unit is not plugged in the option to set the speed will be disabled.
The lsusb command should output something like the string 'Future Technology Devices International, Ltd Bridge(I2C/SPI/UART/FIFO)' if your device is recognized. Mine was an RFDuino
In my case I solved this issue by uninstalling the version of Arduino that I installed via apt-get and instead installed via the official website.
With the latest version of Arduino I didn't have the problem described on Ubuntu 18.04.
So I did with sudo usermod -a -G dialout <my-username>.
You need to log out after you add yourself to a group so those changes are applied. Just log out and log in again and the menu should be available.
install rx-tx lib for java run this command in terminal
sudo apt-get install librxtx-java -y
output port
sudo usermod -aG dialout $USER
sudo apt-get install gnome-system-tools
help regconize usb device
I solved following serial port related problems in ubuntu 18.04 as follows:
Problem 1 : Cannot open /dev/ttyACM0: Permission denied
Solution : Grant permissions to read/write to the serial port with this terminal command ---> sudo chmod a+rw /dev/ttyACM0
Here replace tty port with your respective ubuntu port.
Problem 2 : Failed to open /dev/ttyACM0 (port busy)
Solution : This problem appears when serial port is busy or already occupied. So kill the busy serial port with command ---> fuser -k /dev/ttyACM0. Here replace tty port with your respective ubuntu port.
Problem 3 : Board at /dev/ttyACM0 is not available
Solution : In this case your serial port in tools menu will be greyed out. I googled a lot for this, but I none of solution worked for me. Atlast I tried different arduino board and usb connector and it was working for me. So, if you are having old arduino board (can be solved using required drivers) or defected arduino board then only this problem arises.
If it is helpful to anyone, I had this problem using Ubuntu 22.04. The issue stemmed from:
apparmor (apparmor denied error, logging with dmesg)
brltty (ch34x converter now disconnected from ttyUSB0)
Solved it by removing both:
https://www.simplified.guide/ubuntu/remove-apparmor
sudo apt remove brltty
You can disable apparmor and it should work, however this made applications like firefox useless. My recomendation would be to totally remove it
Same comment as Philip Kirkbride.
It wasn't a permission issue, but using the Arduino IDE downloaded from their website solved my problem.
Thanks!
Michael
The following steps install the IDE and remove the error java.lang.NullPointerException thrown while loading gnu.io.RXTXCommDriver which usually comes with arduino installed with apt-get command in Ubuntu.
Install the IDE
sudo apt-get install arduino
for removing java error in IDE
sudo add-apt-repository ppa:webupd8team/java
sudo apt update
sudo apt install oracle-java8-set-default
This also shows the Serial Port which was grayed out due to the error.
I had the same problem, with which I struggled for few days, reading all the blog posts, watching videos and finally after i changed my uno board, it worked perfectly well. But before I did that, there were a few things I tried, which I think also had an effect.
Extracted the files to opt folder, change the preference --> behavior --> executable text files --> ask what to do. After that, double clicked arduino on the folder, selected run by terminal
added user dialout like described in other answers.
Hope this answer helps you.
For a Windows solution I've found that disabling and re-enabling the Arduino in Device Manager, then restarting the Arduino IDE does the trick without fail (no unplugging necessary). Why this error occurs in the first place is beyond me. Perhaps the corresponding method for Linux will fix your problem.
Slightly related (not really), I had an issue with an AVR board a while back which was fixed by setting the device to a new COM port in the driver settings. Again, however you linux bunnies do it, I'm sure it'll be cookies and cream.
Cheers brother,
I encountered the same issue. My solution was to install and use java7:
sudo apt-get install openjdk-7-jre
sudo update-alternatives --config java
Select the number referring to the java-7 path.
You probably don't have the correct permissions. Try adding yourself to these groups.
sudo adduser username ttyl
sudo adduser username serial
sudo adduser username uucp
Then restart your system and check if you got added to the groups.
groups username
Good Luck!
Try to run as an administrator...
Run terminal, type sudo arduino, type your root password, and... :)

simple and quick tool on linux to watch a http request coming

A HTTP request is coming your way, hitting your machine on a port( assumed that you know the request url/route and the port)
what is a simple and quick tool which helps you watch its headers, parameters being passed, using any language, or any tiny web server proxy, any tool.
Being a ruby/rails guy, I quickly created a rails app, set its routes, ran it, and simply followed its logs.
Curious to know how other web app developers deal with this.
I use WireShark and it is very easy and configurable.
If you use debian or derivates:
sudo apt-get install wireshark
else:
http://www.wireshark.org/docs/wsug_html_chunked/ChapterBuildInstall.html
I'd do this with tcpdump. See the man page. There is also a version for windows.
edit
here's the requested example: tcpdump port 80 (yes, it's that simple). Run it with sudo or as root, otherwise you'll get no suitable device found.
If you need more verbose output, add -v or -vv.
Here is how to use wireshark on a Debian-derived GNU/Linux distro:
$ sudo apt-get install wireshark wireshark-doc
$ sudo dumpcap -i eth0
Ctrl+C
$ sudo chmod 644 /tmp/wireshark_pcapng_eth0...
$ wireshark /tmp/wireshark_pcapng_eth0...

Why doesn't wireshark detect my interface?

I just installed Wireshark, but when I click capture > interfaces, the dialog box appears, but it does not contain my network interface.
When click on capture > interfaces it appears as in the screenshot below. What can cause this?
This is usually caused by incorrectly setting up permissions related to running Wireshark correctly. While you can avoid this issue by running Wireshark with elevated privileges (e.g. with sudo), it should generally be avoided (see here, specifically here). This sometimes results from an incomplete or partially successful installation of Wireshark. Since you are running Ubuntu, this can be resolved by following the instructions given in this answer on the Wireshark Q&A site. In summary, after installing Wireshark, execute the following commands:
sudo dpkg-reconfigure wireshark-common
sudo usermod -a -G wireshark $USER
Then log out and log back in (or reboot), and Wireshark should work correctly without needing additional privileges. Finally, if the problem is still not resolved, it may be that dumpcap was not correctly configured, or there is something else preventing it from operating correctly. In this case, you can set the setuid bit for dumpcap so that it always runs as root.
sudo chmod 4711 `which dumpcap`
One some distros you might get the following error when you execute the command above:
chmod: missing operand after ‘4711’
Try 'chmod --help' for more information.
In this case try running
sudo chmod 4711 `sudo which dumpcap`
In Windows, with Wireshark 2.0.4, running as Administrator did not solve this for me. What did was restarting the NetGroup Packet Filter Driver (npf) service:
Open a Command Prompt with administrative privileges.
Execute the command sc query npf and verify if the service is running.
Execute the command sc stop npf followed by the command sc start npf.
Open WireShark and press F5.
Source: http://dynamic-datacenter.be/?p=1279
For *nix OSes, run wireshark with sudo privileges. You need to be superuser in order to be able to view interfaces. Just like running tcpdump -D vs sudo tcpdump -D, the first one won't show any of the interfaces, won't compalain/prompt for sudo privileges either.
So, from terminal, run:
$ sudo wireshark
As described in other answer, it's usually caused by incorrectly setting up permissions related to running Wireshark correctly.
Windows machines:
Run Wireshark as administrator.
By Restarting NPF, I can see the interfaces with wireshark 1.6.5
Open a Command Prompt with administrative privileges.
Execute the command "sc stop npf".
Then start npf by command "sc start npf".
Open WireShark.
That's it.
On Fedora 29 with Wireshark 3.0.0 only adding a user to the wireshark group is required:
sudo usermod -a -G wireshark $USER
Then log out and log back in (or reboot), and Wireshark should work correctly.
I hit the same problem on my laptop(win 10) with Wireshark(version 3.2.0), and I tried all the above solutions but unfortunately don't help.
So,
I uninstall the Wireshark bluntly and reinstall it.
After that, this problem solved.
Putting the solution here, and wish it may help someone......
Just uninstall NPCAP and install wpcap. This will fix the issue.

What does cifs_mount failed w/return code = -22 indicate

I am trying
sudo mount -t cifs //<server>/<share> -o username=user#domain,password=**** /mnt/<mountpoint>
error message:
mount: wrong fs type, bad option, bad superblock on //server/share,
missing codepage or other error
In some cases useful info is found in syslog - try
dmesg | tail or so
The syslog has
CIFS VFS: cifs_mount failed w/return code = -22
I am able to mount the same share on another centos system. I can ping the server, mount point directory has been created.
I ran into this problem when using a host name and solved it by using an IP address. E.g.:
use
mount -t cifs //192.168.1.15/share
rather than
mount -t cifs //servername/share
Another possible solution is to install
cifs-utils
.
Ah, the dreaded -22. Basically this seems to be used as a catchall for "something didn't work", although technically it's referred to as an invalid argument.
The client does IMHO a very poor job of telling you the actual problem. (This may not be its fault - it doesn't always have access to that information).
However -- have you checked the logs on the server/machine you are connecting to?
I was connecting to an OS X samba server, and learned from what I found in the logs there that it was necessary to specify additional options under -o as follows:
nounix,sec=ntlmssp
Among the things these settings enable are "allow long names", and "ignore UNIX filename endings"...sec is to specify security flags.
Another possibility is that you're trying to access a filesystem of a type that mount.cifs can't actually handle.
For RHEL/Centos install package - "cifs-utils"
Maybe move the target?
sudo mount -t cifs -o username=user#domain,password=**** //<server>/<share> /mnt/<mountpoint>
Or maybe this solution? (Ubuntu, Debian methods)
sudo apt-get install smbfs
Or for CentOS, RedHat, Fedora try:
sudo yum install samba-client
I had a similar issue on Ubuntu 12.04 with the "mount" package (version 2.20.1-1ubuntu3).
It happened when I was trying to mount the server share using its hostname rahter than its IP.
Another way to solve the issue on Ubuntu was to install the cifs-utils package. That way I could also mount the samba share using the exact same command line (or fstab) but with hostname.
sudo mount -t cifs //hostname/share -o username=user,password=pwd /mnt/share
Just did a clean install of Ubuntu 12.04 LTS and got this trying to hook up my Linux HTPC.
Solved it by running: sudo apt-get install cifs-utils then remounting it.
CIFS returns code "-22" in many cases (not only invalid arguments).
For me installing keyutils did the trick:
apt-get install keyutils
My distribution is "Ubuntu 14.04.2 LTS".
I figured this out by increasing the logging verbosity of CIFS:
echo 7 > /proc/fs/cifs/cifsFYI
# disable again via:
#echo 0 > /proc/fs/cifs/cifsFYI
Documentation on the bitmask ("7") for cifsFYI can be found here: https://www.kernel.org/doc/readme/Documentation-filesystems-cifs-README
After trying to mount once more dmesg included more helpful information:
Dec 7 12:34:20 pc1471 kernel: [ 5442.667417] CIFS VFS: dns_resolve_server_name_to_ip: unable to resolve:
Another maybe helpful link:
http://vlkan.com/blog/post/2015/01/08/smb-mount-troubleshoot/
I have Ubuntu Server 12.10 x64 installed as a VMware VM, running on OS X 10.8 (Mountain Lion).
On the Mac, in SYSTEM PREFERENCES > SHARING > FILE SHARING (on), I added a folder to share. For my tests, I created a new folder within my Public folder called "ubuntu".
In Ubuntu, I issued the following commands:
sudo mkdir /media/target
sudo mount.cifs //10.0.20.3/ubuntu /media/target -o username=davidallie,nounix,sec=ntlmssp,rw
Ubuntu prompted me for the password and, once entered, mounted the folder. I then ran:
df -H
which allowed me to verify the mounts and mount-points.
This has recently manifested thanks to a kernel bug in v5.18.8+, I was able to reproduce on v5.18.9 and v5.18.11.
Here is the relevant ticket on kernel.org, quote:
it appears that kernel 5.18.8 breaks cifs mounts on my machine. With
5.18.7, everything works fine. With 5.18.8, I am getting:
$ sudo mount /mnt/openmediavault/
mount error(22): Invalid argument
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel
log messages (dmesg)
The relevant /etc/fstab line is:
//odroidxu4.local/julian /mnt/openmediavault cifs
credentials=/home/julas/.credentials,uid=julas,gid=julas,vers=3.1.1,nobrl,_netdev,auto
0 0
Here is the offending commit, and here is the fix, which applies cleanly to v5.18.11. The cause is, from what I understand, a bug in old versions of the samba server in the negotiation protocol.
If this is your issue, you can:
patch your kernel yourself;
downgrade to v5.18.7;
switch to an LTS kernel;
use the userspace (and also really slow and awful) gvfs-smb;
upgrade the samba version on your server; or
add vers=2.0 to the mount.cifs options in /etc/fstab.
Note that while I haven't tried the last one personally, the venerable #SEBiGEM has confirmed in the comments that it works for v5.18.10.
Note also that I didn't try upgrading samba on the server at all because I hate touching the box it's running on - every time I upgrade anything everything breaks. Doing so might also not be an option for those with NAS appliances.
As a personal sidenote, it's a little sad that so many different things can cause -22. My answer is correct, but very very niche and specific to this point in time. I imagine in a month it will simply be useless noise.
Just experience the problem on RHEL 5. You don't need to install the samba suite, just the samba-client and any dependencies.
Maybe it's too late, but simplest solution described in kernel bug 50631:
in the latest code, unc mount parameter in mandatory. Modified command works for me:
sudo mount -t cifs //<server>/<share> -o username=user#domain,password=****,unc=\\\\<server>\\<share> /mnt/<mountpoint>
Try run the comamnd:
$modinfo cifs
filename: /lib/modules/3.2.0-60-virtual/kernel/fs/cifs/cifs.ko
version: 1.76
description: VFS to access servers complying with the SNIA CIFS Specification e.g. Samba and Windows
license: GPL
author: Steve French <sfrench#us.ibm.com>
srcversion: 9435BBC2F61D29F06643803
depends:
intree: Y
vermagic: 3.2.0-60-virtual SMP mod_unload modversions 686
parm: CIFSMaxBufSize:Network buffer size (not including header). Default: 16384 Range: 8192 to 130048 (int)
parm: cifs_min_rcv:Network buffers in pool. Default: 4 Range: 1 to 64 (int)
parm: cifs_min_small:Small network buffers in pool. Default: 30 Range: 2 to 256 (int)
parm: cifs_max_pending:Simultaneous requests to server. Default: 32767 Range: 2 to 32767. (int)
parm: echo_retries:Number of echo attempts before giving up and reconnecting server. Default: 5. 0 means never reconnect. (ushort)
parm: enable_oplocks:Enable or disable oplocks (bool). Default:y/Y/1 (bool)
If your getting any error then cifs is not installed. Just check with your admin. I thought it helps out.
Adding the option vers=3.0 to the mount command worked for me: sudo mount -t cifs -v <src> <dst> -o ...,vers=3.0,...
You need to install cifs-utils first , just as follows:
sudo yum install cifs-utils
I know this is old, but on older cifs-utils versions, you may have to add the following two lines to /etc/request-key.conf
create cifs.spnego * * /usr/sbin/cifs.upcall -c %k
create dns_resolver * * /usr/sbin/cifs.upcall %k
Workaround without installing additional packages (cifs-utils adds another 81mb in Debian Stretch):
$ FILESERVER_IP=$(getent hosts myfileserver.com | awk '{ print $1 ; exit }')
$ sudo mount -t cifs //${FILESERVER_IP}/<share> -o username=user#domain,password=**** /mnt/<mountpoint>
Many answers, but wasn't work for me.
Solution:
My NAS didn't support Samba 3.0, on which my mount switch automatically.
So I downgraded smb version:
mount -t cifs //192.168.0.2/Share -o rw,vers=1.0,username=*****,password=******* /media/1
It's work.

Resources