Ask Your Question
1

Stopping and Starting Networking 26/Gnome

asked 2017-07-04 05:11:50 -0600

x27qb8 gravatar image

I have written a script to stop networking, change my mac addresses and restart networking.

To stop networking, I'm using the following commands:

sudo -u root ifconfig eno1 down sleep 1 sudo -u root ifconfig wlp2s0 down

The WiFi bars change to a question mark "?"

I then change mac addresses, which appears to work perfectly

Then I use the following commands to restart networking:

sudo -u root ifconfig eno1 up sleep 1 sudo -u root ifconfig wlp2s0 up

The WiFi bars remain a question mark; and I have to disconnect and reconnect to WiFi in Gnome to get network throughput again

Is there a better way to do this? I want everything done inside the script, without manually having to disconnect and reconnect manually in Gnome.

Thanks

edit retag flag offensive close merge delete

Comments

Please share your script for changing your device’s MAC address, and share the link here.

Aeyoun gravatar imageAeyoun ( 2017-07-04 05:40:06 -0600 )edit

!/bin/sh

sudo -u root systemctl stop NetworkManager

sleep 2

sudo -u root ifconfig eno1 down
sleep 1
sudo -u root ifconfig wlp2s0 down

sleep 4

echo ""
echo "Ethernet:"
echo ""
sudo -u root macchanger -m 1c:ab:a7:00:00:01 eno1
echo ""
sudo -u root macchanger -e eno1
echo ""

sleep 8

echo ""
echo "WiFi:"
echo ""
sudo -u root macchanger -m 1c:ab:a7:00:00:02 wlp2s0
echo ""
sudo -u root macchanger -e wlp2s0
echo ""

sleep 8

sudo -u root ifconfig eno1 up
sleep 1
x27qb8 gravatar imagex27qb8 ( 2017-07-05 10:15:41 -0600 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2017-07-04 05:45:38 -0600

Aeyoun gravatar image

You also need to systemctl restart NetworkManager after you bring up the modified network interface. This should take care of updating the NetworkManager extension in GNOME and kickstart the network test.

The question mark is shown when GNOME is either pending or have failed to retrieve a test probe over HTTP. It’s also refetched every five minutes to verify that you connection keeps working. It could indicate that the network connection isn’t working, but it’s not guaranteed to always work (see previous link).

edit flag offensive delete link more
0

answered 2017-07-05 10:18:30 -0600

x27qb8 gravatar image

updated 2017-07-05 12:54:02 -0600

florian gravatar image

Here's the script. I added: systemctl restart NetworkManager

Any improvements appreciated!

#!/bin/sh
sudo -u root systemctl stop NetworkManager
sleep 2
sudo -u root ifconfig eno1 down
sleep 1
sudo -u root ifconfig wlp2s0 down
sleep 4
echo ""
echo "Ethernet:"
echo ""
sudo -u root macchanger -m 1c:ab:a7:00:00:01 eno1
echo ""
sudo -u root macchanger -e eno1
echo ""
sleep 8
echo ""
echo "WiFi:"
echo ""
sudo -u root macchanger -m 1c:ab:a7:00:00:02 wlp2s0
echo ""
sudo -u root macchanger -e wlp2s0
echo ""
sleep 8
sudo -u root ifconfig eno1 up
sleep 1
sudo -u root ifconfig wlp2s0 up 
sleep 4
sudo -u root systemctl start NetworkManager
sleep 2
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-07-04 05:11:50 -0600

Seen: 2,626 times

Last updated: Jul 05 '17