- How do I completely reset network settings?
- 3 Answers 3
- How to Reset Network Interfaces Configuration on Ubuntu Server 18.04?
- How to restart network interfaces on Linux
- What is a network interface?
- How to list network interfaces on Linux
- 1. The ifconfig command
- Как сбросить сетевой адаптер с помощью команды терминала?
- 4 ответа
How do I completely reset network settings?
When I first installed Ubuntu, all networking worked perfectly. After messing with the settings every so often, it slowly became unusable. I would really like to know if there is a way to completely reset network settings without re-installing Ubuntu, DNS settings, proxy settings, everything. I’m running 12.04.
3 Answers 3
It depends what sort of connection you have and whether you have had to manually tweak some settings for it, as sometimes you need to do in the case of a wireless connection.
If you have a wired connection and have simply been altering the settings with Network Manager, you can unplug your Ethernet cable, go into Network Manager and delete all the wired connections (eth0, autoethernet, etc) and then reboot. This has worked for me before. On restart, your wired network will be detected and automatically configured with DHCP to set up ip addresses and DNS settings. This assumes, however, you have a dynamic ip address: you will still have to specify some settings manually if not.
If you have manually altered any settings such as disabling DNSmasq or manually specifying nameservers by creating a fixed resolv.conf , or even changing firewall settings, then you will need to reverse these first and then remove your connections from network manager and reboot.
If none of these approaches are successful, you may need to login to your router and check the settings there.
How to Reset Network Interfaces Configuration on Ubuntu Server 18.04?
I have no idea what I’ve done — but it was all working fine, now it’s not, and I cannot for the life of me figure out what is wrong. How can I completely reset the network interfaces? All I want to do is connect to the internet. I can see the server listed in the Router’s Admin screen, with a dynamic IP address that has been generated through the Routers DHCP server. I’ve tried deleting all contents within the /etc/network/interfaces file I’ve tried deleting all YAML files within /etc/netplan, yet whenever I try to run the command netplan apply I keep getting the error «returned non-zero exit status 4» — Whatever that means. I’ve a feeling that something has got screwed up along the way, and I just need to re-set everything then start from the beginning to get the server accessing the internet (outbound). More Details Previously when I had this working I had a static IP for the box on the network, and I could connect to the internet no problem — I’ve no idea what I changed between it working and not working. What was odd though was that when it stopped working I could see the box had 2x MAC addresses listed on the routers admin page, the static IP that I had configured and another MAC address with the server having it’s own Dynamic IP address. All I can assume there is that I’ve plugged in the Ethernet cable into one of the different network ports in the back of the machine. Here are the outputs to the files as requested; lshw -C network
*-network:0 DISABLED description: Ethernet interface product: I350 Gigabit Network Connection vendor: Intel Corporation physical id: 0 bus info: pci@0000:04:00.0 logical name: enp4s0f0 version: 01 serial: 0c:c4:7a:2a:c8:8a size: 100Mbit/s capacity: 1Gbit/s width: 32 bits clock: 33MHz capabilities: pm msi msix pciexpress bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation configuration: autonegotiation=on broadcast=yes driver=igb driverversion=5.4.0-k duplex=full firmware=1.63, 0x80000a05 latency=0 link=no multicast=yes port=twisted pair speed=100Mbit/s resources: irq:43 memory:c7120000-c713ffff ioport:6020(size=32) memory:c7144000-c7147fff memory:90000000-9001ffff memory:90020000-9003ffff *-network:1 DISABLED description: Ethernet interface product: I350 Gigabit Network Connection vendor: Intel Corporation physical id: 0.1 bus info: pci@0000:04:00.1 logical name: enp4s0f1 version: 01 serial: 0c:c4:7a:2a:c8:8b capacity: 1Gbit/s width: 32 bits clock: 33MHz capabilities: pm msi msix pciexpress bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation configuration: autonegotiation=on broadcast=yes driver=igb driverversion=5.4.0-k firmware=1.63, 0x80000a05 latency=0 link=no multicast=yes port=twisted pair resources: irq:53 memory:c7100000-c711ffff ioport:6000(size=32) memory:c7140000-c7143fff memory:90040000-9005ffff memory:90060000-9007ffff *-network DISABLED description: Ethernet interface product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller vendor: Realtek Semiconductor Co., Ltd. physical id: 0 bus info: pci@0000:84:00.0 logical name: enp132s0 version: 06 serial: 00:13:3b:11:40:dc size: 10Mbit/s capacity: 1Gbit/s width: 64 bits clock: 33MHz capabilities: pm msi pciexpress msix vpd bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=2.3LK-NAPI duplex=half latency=0 link=no multicast=yes port=MII speed=10Mbit/s resources: irq:37 ioport:e000(size=256) memory:f2204000-f2204fff memory:f2200000-f2203fff *-network DISABLED description: Ethernet interface product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller vendor: Realtek Semiconductor Co., Ltd. physical id: 0 bus info: pci@0000:85:00.0 logical name: enp133s0 version: 06 serial: 00:13:3b:11:40:dd size: 10Mbit/s capacity: 1Gbit/s width: 64 bits clock: 33MHz capabilities: pm msi pciexpress msix vpd bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=2.3LK-NAPI duplex=half latency=0 link=no multicast=yes port=MII speed=10Mbit/s resources: irq:37 ioport:d000(size=256) memory:f2104000-f2104fff memory:f2100000-f2103fff
network: ethernets: enp4s0f0: addresses: [192.168.0.04/24] dhcp4: true gateway4: 192.168.0.1 nameservers: addresses: [8.8.8.8,8.8.4.4] version: 2
Note: The above IP address, I’m not sure if I typed that (and did a typo when i did, since last time I was trying to get this working the server showed up in the Routers admin with a .104 IP, not a .04 IP — And at the time of writing this, the server isn’t showing up in the Routers admin at all.
cat /etc/network/interfaces # ifupdown has been replaced by netplan(5) on this system. See # /etc/netplan for current configuration. # To re-enable ifupdown on this system, you can run: # sudo apt install ifupdown
Router's IP Address: 192.168.0.1 Router's Subnet Mask: 255.255.255.0
Update 2 Ok, so after writing the above update about 5 minutes ago, I think I’ve actually got this working (sometimes all you need is some time to stop working on something then come back to it another day!) So here’s what I did, I simply changed the following file so it looks like this instead; cat /etc/netplan/*.yaml
network: ethernets: enp4s0f0: dhcp4: true version: 2
Which I can only assume that because the other bits were in there previously, that Netplan thought that the router was configured with a static IP address rather than a dynamic IP address — or getting confused somewhere along the way since the settings look to be telling itself that it is both static (with the ‘addresses’ setting) and dynamic (with the ‘dhcp4’ setting) at the same time. It’d be good to understand exactly why what I have changed actually works — is my assumption above correct? In addition, does the filename of the .yaml file within /etc/netplan/ actually matter? Not really sure where this comes from, since I recall that the filename is different now than what it was previously when I was deleting / recreating the files. BTW — This is just a test system I’m working on — hence why I can safely just delete things, screw it all up, and try and fix it 🙂 Trying to get a much better understanding of the Ubuntu/Linux architecture and playing around at the minute.
How to restart network interfaces on Linux
O nce you make changes in the network interface, they affect the network services manager of your system. To enable the system or machine to connect to the network, one needs to restart the network interface to apply the changes without rebooting your server.
This article will guide you on restarting the network interface in various Linux distributions.
Note: When running SSH/ VNC or other remote-based sessions, you should take precautions since restarting the network interface or service can result in network disconnectivity, resulting in connection loss.
We will handle the following topics.
What is a network interface?
A network interface refers to the point of connection between a computer and the network. It can be either software (especially with Virtual machines) or a hardware component. When dealing with network interfaces, there is one term that you will likely come across – NIC (Network Interface Card).
A Network Interface Card is a circuit board chip inserted/ soldered on the motherboard allowing your computer to connect to the internet. If you have worked with many earlier Desktop computers (even some today), you know that most cannot connect to a WiFi network, and that’s because they don’t have a wireless NIC. You are advised to purchase a USB Network Adapter that will act as your wireless interface connection in such a situation.
How to list network interfaces on Linux
You can use different ways to see all the available network interfaces on your system. You can use the GUI or the Command-line (CLI). In this post, we highly recommend using the Terminal (CLI) since the GUI settings app might not list specific interfaces.
1. The ifconfig command
This command has long been used to list and configure network interfaces on Linux. Unfortunately, this command is marked as ‘deprecated’ and does not come pre-installed in certain distributions like recent Debian and Kali Linux releases.
To list network interfaces using ifconfig, execute the command below.
Как сбросить сетевой адаптер с помощью команды терминала?
Что ж, когда я выключаю маршрутизатор, а затем снова включаю его во время работы Ubuntu, он не получает IP-адрес автоматически:
Я нажимаю на отключить, но он остается, как указано выше.
Это работает, только если я выйду из системы и переключусь на другой сеанс, а затем вернусь к сеансу по умолчанию.
Итак, как мне сбросить сетевой адаптер с помощью команды терминала или каких-либо других предложений?
Изменить: я пытался использовать sudo dhclient , но это не сработало.
4 ответа
Если вы действительно хотите сбросить сетевой адаптер, вам обычно нужно выгрузить и перезагрузить модуль ядра, который он использует.
Если вы просто хотите перенастроить его, вы обычно можете сделать:
sudo /etc/init.d/network-manager restart
Но если вы просто хотите получить новую аренду dhcp (это техническое имя для получения нового IP-адреса от маршрутизатора), вам просто нужно использовать:
Это звучит как проблема сетевого менеджера для меня.
Я бы попробовал следующее: (в терминале гномов)
- «Softblock» вашего беспроводного устройства с rfkill block wifi
- rfkill list покажет вам, если вы были успешны.
- killall nm-applet Вы убиваете процесс сетевого администратора (значок панели исчезнет).
- rfkill unblock wifi Включите Wi-Fi снова.
- nm-applet Загрузите новый сеанс сетевого менеджера.
Может быть, просто убить / загрузить nm-applet. Также обратите внимание, что вам не нужно использовать sudo для этого.
Я знаю, что некоторые маршрутизаторы и устройства Wi-Fi не очень хорошо «любят» друг друга. Это часто проблема как-то «бета» Wi-Fi Linux-драйвера.
nmcli radio wifi off nmcli radio wifi on
Я написал сценарий, чтобы попробовать различные методы для сброса Wi-Fi, когда он разорвал соединение или по другим причинам не отвечает (он вызывается каждые 2 минуты в cron):
#!/bin/sh # program to check wifi and reset if not running IPTEST=192.168.1.1 iwconfig=/sbin/iwconfig rfkill=/usr/sbin/rfkill DEVICE=`$iwconfig | egrep 802 | awk ' '` if ping -c 1 $IPTEST >/dev/null 2>&1 ; then #echo $IPTEST ok exit 0 else # Failed, try to reset wifi - sometimes works ok ( date echo "Apagando wifi. " nmcli nm wifi off sleep 3 echo Iniciando wifi. nmcli nm wifi on sleep 10 if ping -c 1 $IPTEST >/dev/null 2>&1 ; then #echo $IPTEST ok exit 0 else # try another way echo "Apagando wifi $iwconfig . " $iwconfig $iwconfig $DEVICE txpower off sleep 3 echo Iniciando wifi. $iwconfig $DEVICE txpower auto fi sleep 10 if ping -c 1 $IPTEST >/dev/null 2>&1 ; then #echo $IPTEST ok exit 0 else # try another way echo "Apagando wifi $rfkill . " $rfkill list $rfkill block wifi sleep 3 echo Iniciando wifi. $rfkill unblock wifi fi #echo Cerrar esta ventana cuando sale el estado #sleep 3 #iftop -i $DEVICE ) >> $HOME/wificheck.log 2>&1 fi exit 0