I just installed Ubuntu 17.10, and Mininet 2.2.2 from Packages (sudo apt-get install mininet
) on my laptop. Natively, i.e. a real OS on a real machine, no virtual machines of any sort. The laptop is a 2017 MacBook Pro 13" without touchbar (MacBookPro14,1), and Ubuntu runs on a fast USB key; just writing for completeness, I don't think it's relevant.
I need CLI access to each Mininet host that I'm going to create, in order to run custom tests and observe the traffic that passes by in each node.
On my former laptop, I had a similar setup but with older versions of Ubuntu and probably also Mininet, and I managed to be able to spawn xterm
s from every Mininet host that I wanted. The problem is, I don't remember at all how I did it =).
echo $DISPLAY
returns :0
whether I run it in a regular shell or in a Mininet host, but in a regular shell xterm
opens an xterm window. Let's say h1
is my Mininet host. I start Mininet with sudo mn
and I get:
h1 echo $DISPLAY
--> :0
xterm h1
--> nothing, and nothing happens h1 xterm &
--> nothing, and nothing happens h1 xterm
--> No protocol specified. Warning: This program is an suid-root program or is being run by the root user. The full text of the error or warning message cannot be safely formatted in this environment. You may get a more descriptive message by running the program as a non-root user or by removing the suid bit on the executable. xterm: Xt error: Can't open display: %s
All info that I could find is related to X11 forwarding with ssh, and everything I've tried failed.
Any idea?
Run xhost +local:
in a terminal without being superuser to fix the issue. Below the details.
The issue is due to xterm not working by default when authenticated as superuser (Mininet has to be run as superuser), for security reasons.
You can check if this is your issue by running xterm
and sudo xterm
in a terminal when being logged in as usual (if you did something like sudo su
before this check is pointless).
If xterm
opens, but sudo xterm
doesn't, then you need to run
xhost +local:
sudo xterm
should work now, as well as h1 xterm
inside Mininet.
This is because with that command you provided graphical server access to applications running as sudo
or su
.
The setting won't persist between reboots, and it can be reverted with xhost -
.
Please note that by doing this, you are giving any user on the system or the network access to your $DISPLAY without authentication (https://wiki.archlinux.org/index.php/Xhost).