Setting network device priority with nmcli in Fedora - networking

I am on Fedora v33 Server edition (no GUI) and I have setup 2 network connections.
One is Ethernet, which I use to connect my Macbook to the Linux machine, the other is the WLAN connection the machine uses to connect to the internet.
So now whenever I do
nmcli con up eno1
I lose access to the Internet (ping www.google.com does not return any packets)
When the ethernet is down everything works, but I cannot use ethernet obviously.
Something similar can happen on a Mac OS where I can simply "drag" a network to set the priority. How do I do the same using only the terminal on a unix system like Fedora?

Ok after some research I ran into this great tool called nmtui
sudo dnf install NetworkManager-tui
And after installing the tool and running it with sudo nmtui I edited my ethernet connection and saw the option called
Never use this network for default route which translates to the option never-default=true inside the [ipv4] in the /etc/NetworkManager/system-connections/ config file.
After that I ran sudo nmcli con down eno1 && sudo nmcli con up eno1 and after running nmcli again I can see that the order of connections charged, where now my WLAN is first and my ethernet connection is second.

Related

Google Cloud virtual machine instance created from snapshot not allowing ssh

I have created a virtual machine instance from snapshot taken the production server. SSH key is set. But I am unable to ssh into instance both from the putty and google cloud ssh option from browser.
I have search around and find out that the issue new release which does not set the
default IP gateway for the instance. I have set the IP gateway and restart the instance but instance still showing the same error .
I have also check the Firewall rule and port 22 traffic allowed to the instance.
All other instance in same zone are working on SSH other than instance newly created using snapshot.
After looking into the logs from the serial port ifup: failed to bring up lo
Image of the error
#Patrick answer helps me get to answer, explanatory steps
1) Serial Console.
Go to you instance detail and enable serial port.
Connect to your instance using serial port and login with the user and password
If you do not have user create one by following script as a startup-script
#!/bin/bash
sudo useradd -G sudo user
sudo echo 'user:password' | chpasswd
sudo systemctl status networking.service to check networking status
Remove the /etc/network/interfaces.d/setup file then edit your /etc/network/interfaces
auto lo
iface lo inet loopback
Restart networking service by running sudo systemctl status networking.service
2) Following startup script also work for me
#!/bin/bash
sudo dhclient eth0
It seems the issue here is that the network interface of your new instance is not coming up. You can try one of two steps:
1) try connecting through the serial console. This does not connect through port 22 or use SSH. However, if the network card is not coming up at all, this may also fail.
2) Add a startup script to the instance which will run the commands you need to configure the network card

raspberry, switch between wifi and hotspot

I am working on a raspberry for a POC demo.
My raspberry needs to be set up as a hotspot and that went fine following this tutorial: https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md
However I can't get to easily switch between a "normal" wifi and the hotspot. I need to get back to a normal behavior to download packages to the raspberry for instance.
I found : http://sirlagz.net/2013/01/22/script-starting-hostapd-when-wifi-goes-down/ . Typing the same command does not seem to do the job.
What I've tried is :
Raspberry set up as hotspot
Stop dnsmasq and hostapd
edit /etc/dhcpcd.conf (to remove the static ip configuration)
restart dhcpd
I can see the raspberry is connected to the correct wifi but apparently I have no internet connection and can't download any packages.
Maybe there is something more to do about the iptables but I really don't know much about that and I prefer not screwing all my configuration.
Any idea about the procedure to switch between the two "modes"?
Cheers
I have found a solution that works perfectly.
Disable access point :
sudo systemctl disable hostapd dnsmasq
comment the static ip config in /etc/dhcpcd.conf
sudo reboot
Enable access point
sudo systemctl enable hostapd dnsmasq
comment the static IP config in /etc/dhcpcd.conf
sudo reboot
The difference is instead of just stopping the 2 services I completely disable them.

Mininet+ GNS3: pingall fails + dhcp doesn't work

I'm still a beginner, I'm facing some issues and I need your help.
1
I integrated mininet to gns3 successfully, the mininet VM can ping all the routers and other VMs, Also it can get an address through dhcp immediately without problems. However, when I run this command,
sudo mn --controller=remote,ip=192.168.1.10, port=6653
the ovswitch connects to the floodlight controller but pingall fails.
2
I tried to add my network interface (eth0) to the my bridge (s1) in order to connect the mininet host to the internet, the dhclient takes long time and can't assign an IP address to the bridge.
add eth0: ovs-vsctl add-port s1 eth0
remove eth0's IP addressing: ifconfig eth0 0
make s1 interface get a DHCP IP: dhclient s1
Im using:
floodlight master
ovs_version 2.5.4
GNS3 version 2.1.8 on Windows (64-bit) with Python 3.6.5 Qt 5.8.0 and PyQt 5.8.
ubuntu 16.04.4
Please can someone help me to solve these issues.
Thanks in advance.

Centos VM with Docker getting host unreachable when trying to connect to itself

I have Docker running on a Centos VM, with bridged network. running
ifconfig
shows that my VM gets a valid IP address. Now I'm running some software within a docker container/image (which works within other docker/networking configurations). Some of my code running in the docker container uses SSL Connection (java) to connect to itself. In all other run configurations, this works perfectly. But when running in bridged mode with Centos VM and docker-compose, I'm getting an SSL Connect exception, error: Host unreachable. I can ping to and ssh into the VM with the same IP address and this all works fine. I'm sorry that I can't post actual setup/code and scripts as it's too much to post and it's also proprietary.
I'm baffled by this - why am I getting Host Unreachable in the aforementioned configuration?
FYI, I resolved the problem on centos by using the default "bridged" containers provided by Docker, but adding the following to my firewalld configuration:
firewall-cmd --permanent --zone=trusted --add-interface=docker0
firewall-cmd --reload
service firewalld restart
You might also need to open up a port to allow external communication, like so:
firewall-cmd --zone=public --add-port=8080/tcp --permanent
My solution was to switch to an Ubuntu VM, because switching my docker compose to the default "bridged" network broke my aliases, which I really needed
The only remaining question here is why after configuring firewalld, a user-configured network on docker-compose cannot access the external IP, forcing us to switch to the default bridged network

playing with tcp/ip

I'd like to learn and play with tcp/ip libraries for python, java or c++. But I only have one computer. Is it possible to "fake" remote computers to emulate remote hosts, under NAT end everything?
The simplest way is to run both the server and client on the same computer and use the "loopback" IP address: 127.0.0.1 which always connects to the local host. I've done this many times during testing. For example, run a local webserver on port NNN and then in the browser enter http://127.0.0.1:NNN/ In fact, 127.X.Y.Z should always talk to the local machine.
If you are using linux, you can configure dummy interfaces, then bind your client / server to different dummy interfaces.
[mpenning#Bucksnort ~]$ sudo modprobe dummy
[mpenning#Bucksnort ~]$ sudo ip addr add 192.168.12.12/24 dev dummy0
[mpenning#Bucksnort ~]$ ip addr show dummy0
6: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN
link/ether b6:6c:65:01:fc:ff brd ff:ff:ff:ff:ff:ff
inet 192.168.12.12/24 scope global dummy0
[mpenning#Bucksnort ~]$ ping 192.168.12.12
PING 192.168.12.12 (192.168.12.12) 56(84) bytes of data.
64 bytes from 192.168.12.12: icmp_seq=1 ttl=64 time=0.085 ms
^C
--- 192.168.12.12 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.085/0.085/0.085/0.000 ms
[mpenning#Bucksnort ~]$ sudo modprobe dummy -o dummy1
[mpenning#Bucksnort ~]$ sudo rmmod dummy
[mpenning#Bucksnort ~]$ ip addr show dummy0
Device "dummy0" does not exist.
[mpenning#Bucksnort ~]$
You should be able to run ipchains on these interfaces just like any other.
You can start out with talking between programs on your own computer.
You can use virtual machine software such as VirtualBox, VMWare, VirtualPC, etc to create what is essentially a second machine within yours and talk to that (though the network topology may be very slightly unusual - something more to learn about)
If you want to talk to something remote, you can rent a small cloud server running linux or windows from the likes of Amazon for pennies an hour and install whatever you want on it.
Use virtual box to install OS in your system. for any networking application, this is best. You dont have to work on two different system and its easy to see whats happening at both ends
Run to server to listen on your network adapter, or localhost. Then issue requests to that same IP and Port. Logically, it will all take place within the network driver(s), but it will still behave the same way if that IP address were addressed to another machine (barring Firewall configurations, etc)

Resources