date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,405,769,071,000 |
I am using Ubuntu and am just curious as to tell the name of all network interfaces, even the ones I've taken down with sudo ifconfig wlan0 down (for example) as they no longer show up in ifconfig.
|
You can use ifconfig -a or ip a l.
| How to get the name of a network interface that is down |
1,405,769,071,000 |
I'm trying to understand the syntax of ifupdown a bit better, and on several sites detailing fairly straightforward static configurations, the example documentation includes a line stating `network 192.168.0.0' -- or something obviously similar. For example,
# The loopback network interface
auto lo eth0
iface lo inet loopback
# The primary network interface
iface eth0 inet static
address 192.168.10.33
netmask 255.255.255.0
broadcast 192.168.10.255
network 192.168.10.0
gateway 192.168.10.254
dns-nameservers 192.168.10.254
What exactly does this line do? I can't imagine that it contains anything that the netmask + address doesn't convey about, for example, broadcast addresses. There is much useful documentation about the myriad array of powerful things that one can do with /etc/network/interfaces available online. Almost all of it details various aspects of networking. Therefore, googling isn't terribly helpful!
|
The network doesn't have to be specified as it is simply the result of address & netmask (& is a binary and):
192.168.10.33 & 255.255.255.0 = 192.168.10.0
It may make it easier to understand by showing it in binary:
11000000.10101000.00001010.00100001 (192.168.10.33)
& 11111111.11111111.11111111.00000000 (255.255.255.0)
-------------------------------------
11000000.10101000.00001010.00000000 (192.168.10.0)
| In Debian-derived flavours, what does the 'network' line in /etc/network/interfaces actually do? |
1,405,769,071,000 |
I'm trying to list all network interfaces in Windows Subsystem for Linux shell but I got this error message:
Warning: cannot open /proc/net/dev (File o directory non esistente). Limited output.
Any suggestion?
|
Making my comment a proper answer, as of the day of this writing, the feature is probably not yet implemented.
Since /dev is a special file system created by the Linux kernel on demand, every part of it needs to be implemented in the Windows Subsystem for Linux
| Cannot list network interfaces in Windows Subsystem for Linux |
1,405,769,071,000 |
I have a wlan1 connection that I want to share to other computers on my LAN (via Ethernet - eth0). As this is somehow a temporary solution, I want this to be done by a script, so that I do not touch the network configuration files of my host (i.e I'll run this script after each reboot if I want to).
The problem is that I am unable to bridge wlan1 and eth0.
sudo brctl addif br0 eth0 wlan1
I saw that one needs to enable 4addr:
iw dev wlan1 set 4addr on
Indeed, I can then add wlan1 to the bridge, but ... I lose the wifi connection! I saw this is also a common issue :(
In 2, the solution says to do this
iw dev wlan0 interface add wds.wlan0 type managed 4addr on
ip link set dev wds.wlan0 addr $ADDR
ip link set dev wds.wlan0 up
where $ADDR is "WDS device address configured in the router". I don't understand what that is? The MAC address of my network card for wlan1?
And how should I then create my bridge? The following is not working:
sudo brctl addbr br0
sudo brctl addif br0 eth0 wds.wlan0
Or here, they suggest to install ebtables. But the page does not explain how I should create the bridge, and they modify /etc/network/interfaces which I do not want to do...
So, can somebody please help me create that bridge correctly?
So far, my wifi script is:
#!/bin/bash
# this is for wlan1 - wifi connection
pkill dhclient
pkill wpa_supplicant
ip link set dev wlan1 down
ip addr flush dev wlan1
iwconfig wlan1 essid "mywifi"
iwconfig wlan1 frag 2432
iwconfig wlan1 rts 2432
ip link set dev wlan1 up
iwconfig wlan1 rate 1M
dhclient -v wlan1
# this is my IP address on my LAN
ifconfig eth0 192.168.0.8 netmask 255.255.255.0
I am running a Linux Mint 17.1 host. I have installed bridge-utils.
|
Is it possible to bypass the bridging part and use iptables instead?
If so, you can setup source NAT to masquerade traffic going out on the wlan interface.
First you need to enable IP forwarding:
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
Next, you need to masquerade traffic going out:
sudo iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j MASQUERADE
Have the LAN connected hosts to use 192.168.0.8 as their default gateway and have your machine to use the wlan0 interface connected gateway as the default gateway.
| Share wlan connection to ethernet using command line |
1,405,769,071,000 |
I am trying to unlock my root encrypted Debian Buster on an acepc T11. I installed dropbear, added
DEVICE=enp1s0
IP=:::::enp1s0:dhcp
to /etc/initramfs-tools/initramfs.conf and executed update-initramfs -k all -u. When the initramfs is loaded, I get multple times the error
ipconfig: enp1s0: SIOCGIFINDEX: No such device
ipconfig: no devices to configure
and a single time the error
/scripts/init-premount/dropbear: .: line 275: can't open '/run/net-enp1s0.conf': No such file or directory
I can then only proceed by entering the LUKS password at the machine.
A few things I tried:
The interface enp1s0 is the one that is shown by ip a once the system is fully booted, but seems to be incorrect in the initram?! I tried to omit the interface name so the initram would figure the correct one out by itself, but then I still receive the ipconfig: no devices to configure errors and the last error changes to /scripts/init-premount/dropbear: .: line 275: can't open '/run/net-*.conf': No such file or directory.
I also tried the "standard" interface names eth0 and eth1 but got the same errors.
I edited /boot/cmdline.txt according to this answer, but that didn't help.
I added virtio, virtio_pci and virtio_net to /etc/initramfs/modules as that seemed to help someone with a similar issue (can not find the webpage anymore), but with no success.
I added ip=dhcp to GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub as described in this article. No change at all.
I created the file /etc/initramfs-tools/conf.d/cryptroot with content target=mmcblk0p3_crypt,source=UUID=49429a5f-f094-485c-8c2e-45f53f81919f as suggested on this Q/A site. (The content of /etc/crypttab ist mmcblk0p3_crypt UUID=49429a5f-f094-485c-8c2e-45f53f81919f none luks,discard,initramfs, by the way.)
My guess is, that either the network is not up or a driver is missing in that initramfs phase or I have the wrong interface name, but I do not know how to fix the first or how to find out the correct name.
Any help is appreciated.
|
Turned out, that indeed the network driver was missing in the initramfs. The module argument MODULES=most in /etc/initramfs-tools/initramfs.conf was not sufficient. Thanks to this answer, I found my network driver using lspci -v and added the appropriate module to /etc/initramfs-tools/modules. After rebuilding the initramfs, I still receive an error about some module that can not be loaded but the network is running nonetheless and I can unlock the LUKS device remotely.
| Unlock LUKS device remotely - ipconfig: no devices to configure |
1,405,769,071,000 |
I have an embedded system running Ubuntu 18.04 LTS that has a 3G modem and an Ethernet interface (eth0).
Both of these interfaces have access to Internet.
When the internet is unavailable on the Ethernet interface (cable is unplugged), I want to set the default gateway to the one of the 3G modem automatically, so the system can always access the internet.
For now, for test purposes and for the sake of simplicity, I'm substituting the 3G modem with another ethernet interface (a USB Ethernet adapter connected to another network - interface enxd037458b96e3) and I noticed that when the Ethernet connection is lost on eth0 (its cable is connected to a 4 port gigabit router) the default gateway disappears and I don't have access to internet whereas the USB Ethernet interface is active (and its IP address is automatically assigned with DHCP just like eth0).
In that case, this is the output of the route command :
$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 uap0
192.168.137.0 0.0.0.0 255.255.255.0 U 0 0 0 enxd037458b96e3
Whereas when the eth0 is up or recoverd :
$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.30.102 0.0.0.0 UG 0 0 0 eth0
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 uap0
192.168.30.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.137.0 0.0.0.0 255.255.255.0 U 0 0 0 enxd037458b96e3
Below, the content of this /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
iface eth0 inet dhcp
# post-up route add default via [gateway-ip-address] dev eth0
# interface usb eth
allow-hotplug enxd037458b96e3
iface enxd037458b96e3 inet dhcp
# auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
auto uap0
# allow-hotplug uap0
iface uap0 inet static
address 192.168.2.10
netmask 255.255.255.0
broadcast 192.168.2.255
post-up /etc/rc.apstart || true
# post-up /bin/uaputl.exe sys_cfg_80211d country DE || true
# post-up /bin/uaputl.exe sys_config /etc/uapTest.conf || true
# post-up /bin/uaputl.exe bss_start || true
post-down /bin/uaputl.exe bss_stop
post-down /bin/uaputl.exe sys_reset
# post-up /sbin/ifconfig uap0 192.168.0.2
UPDATE:
Unlike the eth0 interface, when I unplug the cable from USB Ethernet adapter, route always shows the default gateway of this last. With the eth0 interface, the default gateway disappears and will be back only if the cable is plugged on it.
$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.137.1 0.0.0.0 UG 0 0 0 enxd037458b96e3
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 uap0
192.168.30.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.137.0 0.0.0.0 255.255.255.0 U 0 0 0 enxd037458b96e3
|
Similar to this question : https://askubuntu.com/questions/948453/internet-connection-stops-after-one-interface-is-down-in-ubuntu-server I will use NetworkManager to manage my connections (3G too).
However, when the internet access is lost on the interface that has the lowest metric, the system cannot access to internet anymore whereas an interface having a higher metric but connected to internet exist (e.g. a 3G modem), in that case we do need to manually increase the metric of the interface not connected to internet.
I will see if I can request a new system image with the interface bonding built in it.
Otherwise, one can write a service to monitor if the default route with the lowest metric is connected to internet and can control the NetworkManager.
| Use the internet access of another network interface when the main one is down |
1,548,939,342,000 |
I'm setting up a Raspberry Pi running Raspbian with some specialized software and with the intent to ship it out to a customer and just have them plug it in and work. However, since the customer is in a different location, it will obviously have never connected to their wifi network before. It would be ideal if I could configure it with the SSID and password (both of which I have) ahead of time so that when the customer plugs it in, they don't have to do anything (i.e. it just works).
Are there are command line utilities, or /etc files to edit, that will allow me to set up a wireless network ahead of time?
|
So I figured it out... basically you have to edit the /etc/wpa_supplicant/wpa_supplicant.conf file, and add an entry like this one:
network={
ssid="My_Network_Name"
psk="password"
key_mgmt=WPA-PSK
}
| How can I preconfigure a wireless network I haven't seen yet? |
1,548,939,342,000 |
In the Linux-Ubuntu terminal:
ifconfig throws bash: ifconfig: command not found
locate command does the same.
sudo yum install net-tools throws: bash: yum: command not found as well, but I might also have made a spelling mistake there when I tested it.
What does it mean, do I have to install ifconfig? Or are there alternative commands?
|
Different distributions of linux have different tools to install packages, known as package managers - you need to use the right one for your distribution. Yum is the package manager for Red Hat systems. Instead, you need to use apt, Ubuntu's package manager. Try:
sudo apt install net-tools locate
That pattern should work for most packages on Ubuntu. net-tools is the package which contains ifconfig on Ubuntu. HOWEVER, ifconfig is well out of date and has been for several years. You should use ip, which should be installed already in Ubuntu.
| ifconfig and locate command not found, `bash: ifconfig: command not found` |
1,548,939,342,000 |
Does ifconfig show the MAC address of a network interface following ether?
Does ether mean ethernet? How does it mean Mac address?
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:b1:aa:1f txqueuelen 1000 (Ethernet)
RX packets 451 bytes 43572 (43.5 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 108 bytes 28182 (28.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlx8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.97 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 xx:xx:xx prefixlen 64 scopeid 0x20<link>
ether 80:1f:02:b5:c3:89 txqueuelen 1000 (Ethernet)
RX packets 697657 bytes 564556036 (564.5 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 374913 bytes 60332457 (60.3 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
As explained in the ifconfig manpage, in the section on setting options,
Set the hardware address of this interface, if the device driver supports this operation. The keyword must be followed by the name of the hardware class and the printable ASCII equivalent of the hardware address. Hardware
classes currently supported include ether (Ethernet), ax25 (AMPR AX.25), ARCnet and netrom (AMPR NET/ROM).
This also explains the output, i.e. ifconfig shows the current hardware address of the interface, with its hardware class. For Ethernet interfaces, the class is ether and the hardware address is the MAC address.
| Does `ifconfig` show the MAC address of a network interface following `ether`? |
1,548,939,342,000 |
Depending on the distribution, invoking ip link set <iface> up (or down; also ifup / ifdown) will look at various config files (/etc/network/interfaces on Debian I think, Gentoo has /etc/conf.d/net...), and make changes (e.g. interact with DHCP etc.)
As far as I have seen from strace, the ip command talks to the kernel directly (is this so?). But then, eventually, someone launches those shell scripts / reads the config. What's the mechanism behind this happening? Is the init system listening on some kernel interface for up / down state changes and launches these scripts? Or is it something different?
|
Invoking ip link set <iface> up as you describe is just doing the minimal communication with the kernel over the rtnetlink API (which is not only about routes, but also links, addresses etc. Here it would be RTM_NEWLINK) to bring the interface administratively up. Older ifconfig tool asks the same to the kernel using the deprecated (for network) ioctl API (here that would be SIOCGIFFLAGS).
These commands are low level commands that do only what was asked and nothing more.
ifup is part (on Debian) of the ifupdown (or the alternate ifupdown2) suite, and has different implementations on different Linux distributions. They are just a suite of scripts, probably invoking ip link set ... themselves, and maybe some of them will also directly use other available tools (like NetworkManager). So you absolutely can't put them at the same level: ip link set ... up is not at all ifup ....
Now how would other networking tools like NetworkManager interact and know what happened? Because they are asking the kernel, through rtnetlink, to be notified of some network events they are interested in. The netlink API implementation supports multicast: that means a single message can be efficiently received by multiple interested parties (belonging to userspace or kernel) so this simplifies the events implementation.
Typically, when something (here ip link set ... up) sends a message to the kernel, the kernel replies with a message that is multicasted to interested parties: The ip link command receives this message back, but also all waiting tools that now know that "an interface was just brought up" (I'll leave aside the differences between administrative state up versus operational state up).
It's possible to do the same in a script using an event loop driven by the output of the command ip monitor which is waiting for network events from the kernel. Of course a really parsable output would be preferable, sadly while many other iproute2 sub-commands support a JSON output (using -json) that's not the case for ip monitor.
Here's a basic shell example based on ip monitor link to display the oper status of an interface whenever a change to this interface is done (even if it's not related to its oper status.. that's a basic example). As it's parsing unreliable output, expect it to fail for some cases:
#!/bin/sh
ip -o monitor link | while read -r index interface status remaining; do
iface=$(printf '%s\n' "$interface" | sed -E 's/(@.*)?:$//')
operstate=$(printf '%s\n' "$remaining" | grep -Eo ' state [^ ]+' | sed 's/^ state //')
printf '%s %s\n' "$iface" "$operstate"
done
While the script above is running try these commands elsewhere:
# ip link add test1 type veth peer name test2
# ip link set test1 up
# ip link set test2 up
# ip link delete test1 # script doesn't handle correctly lines starting with Deleted
Same is possible with addresses, routes etc. That's how tools like NetworkManager are reacting to the command ip link set <iface> up.
| ip link set <interface> up / down: how are scripts called? |
1,548,939,342,000 |
According to a computation I did on the data from ifconfig, my ethernet connection between my router and computer averages 1298 bytes/packet for TX (close to the MTU of 1500) and only 131 bytes/packet for RX. What could cause such a large discrepancy in the average TX vs. RX packet sizes?
|
One possibility is that if you are sending data out predominantly, most of the packets coming back to your system will be ACKs, and those are going to be much smaller than the PUSH you're sending.
| What can cause a large TX vs. RX average bytes/packet discrepancy? |
1,548,939,342,000 |
I have a fedora core machine, and it is picking up an IPV6 address, but not an IPV4 address. I have done dhclient -r eth0 but the ipv4 address has not come. I have reset the port using ifconfig, but the address keeps coming up as an IPV6 address.
|
It's possible that the lightning strike destroyed the network port on your machine, and that the IPv6 address is a self-assigned address. Have you tried using the 'ping6' command to try pinging an outside IP address via IPv6 to really ensure that you've got IPv6 connectivity to the outside world?
Also, I concur with mattdm here -- FC4 is very old -- it's definitely worth looking to upgrade to a more modern version of Fedora.
| Fedora Core 4 won't get an IPV4 address |
1,548,939,342,000 |
I have been trying to install the OpenVPN Access Server on my CentOS 7 VPS. However, I have been running into a number of problems.
Initially, I had followed this DigitalOcean guide, but after I had problems using that, I later found out that I meant to install the Access Server. I found this DigitalOcean guide for CentOS 6.5, and just adapted it to CentOS 7.
I'm beginning to wonder if following the instructions of the two different guides is what has caused my problems. I am able to start the service via command line, but I am not able to start it via the web interface.
$ sudo systemctl status [email protected]
[email protected] - OpenVPN Robust And Highly Flexible Tunneling Application On server
Loaded: loaded (/usr/lib/systemd/system/[email protected]; enabled)
Active: active (running) since Thu 2015-03-05 08:12:53 EST; 3s ago
Process: 1738 ExecStart=/usr/sbin/openvpn --daemon --writepid /var/run/openvpn/%i.pid --cd /etc/openvpn/ --config %i.conf (code=exited, status=0/SUCCESS)
Main PID: 1745 (openvpn)
CGroup: /system.slice/system-openvpn.slice/[email protected]
└─1745 /usr/sbin/openvpn --daemon --writepid /var/run/openvpn/server.pid --cd /etc/openvpn/ --config server.conf
Mar 05 08:12:53 arguru systemd[1]: Failed to read PID from file /var/run/openvpn/server.pid: Invalid argument
Mar 05 08:12:53 arguru openvpn[1745]: GID set to nobody
Mar 05 08:12:53 arguru openvpn[1745]: UID set to nobody
Mar 05 08:12:53 arguru openvpn[1745]: UDPv4 link local (bound): [undef]
Mar 05 08:12:53 arguru openvpn[1745]: UDPv4 link remote: [undef]
Mar 05 08:12:53 arguru openvpn[1745]: MULTI: multi_init called, r=256 v=256
Mar 05 08:12:53 arguru openvpn[1745]: IFCONFIG POOL: base=10.8.0.4 size=62, ipv6=0
Mar 05 08:12:53 arguru openvpn[1745]: IFCONFIG POOL LIST
Mar 05 08:12:53 arguru openvpn[1745]: Initialization Sequence Completed
Mar 05 08:12:53 arguru systemd[1]: Started OpenVPN Robust And Highly Flexible Tunneling Application On server.
However, from the web panel, I receive this error.
I have tried searching multiple different resources about this, and some said the issue was that the web interface was not starting the VPN as root, which is why the ifconfig error occurred, and the second error regarding the binding failed only happens when I start OpenVPN via command line.
I realize I probably made some mistakes setting this up, but I want to know how I can fix this now without reinstalling my entire operating system (this VPS is for my own learning and experimentation). Any help is appreciated!
|
Running on Amazon Linux 2016.03 using this package in order to get the server running after the rpm install succeeded, I needed to:
sudo ln -s /sbin/ifconfig /usr/sbin/ifconfig
The reason openvpnas couldn't execute ifconfig, is because it was trying to run /usr/sbin/ifconfig. The symbolic link fixed it.
| CentOS 7 - Cannot start OpenVPN Access Server |
1,548,939,342,000 |
Anyone know how to createa bridge network interface on MacOS v12.4 Mon?
I have tried:
sudo ifconfig bridge7 create
sudo ifconfig bridge7 addm en0
sudo ifconfig bridge7 up
In step two I get this:
ifconfig: BRDGADD en0: Resource busy
|
Short answer: see the Apple Support article "Bridge virtual network interfaces on Mac".
Long answer: On macOS, you generally shouldn't use ifconfig to modify the network setup; that'll change the "live" interface state, but it tends to get overwritten by the system configuration daemon (configd) setting things to the way it thinks they should be. Instead, use networksetup or the System Preferences utility to change the system config database, and let configd apply those changes to the live network state.
Unfortunately, networksetup doesn't seem to have options to create and manage bridge interfaces, so you'll need to use System Preferences:
On your Mac, choose Apple menu > System Preferences, then click Network.
Click the Action pop-up menu ("..." or gear icon), then choose Manage Virtual Interfaces.
Click the Add button (+), choose New Bridge, then select the interfaces to include in the bridge.
Click Create, then click Done.
| ifconfig bridge on macos - BRDGADD en0: Resource busy |
1,548,939,342,000 |
I have this output via ifconfig:
user@host:~$ ifconfig eth0 | grep bytes
RX bytes:999249172034 (999.2 GB) TX bytes:33403577196 (33.4 GB)
The host has 7 days uptime.
Are the RX bytes and TX bytes counted since the host has been up, or over the lifetime of the host, and the value just "wraps" around when the value gets too big?
|
Over the lifetime of the interface, as far as I can tell. That is, if the interface goes away, like if you unload the driver module, the counters will be zeroed when you add it back. (Probably the same if you unplug and reconnect a USB interface, but I didn't test that.) Restarting the system would also reset them, yes.
As far as I can see, there's no way to explicitly clear the counters: a quick search resulted in multiple suggestions to unload and reload the driver in question, and that was pretty much the only suggestion there was.
That's not entirely odd though, since the counters are mostly used so that software monitoring them stores the last value it saw, and calculates the difference when it fetches the value the next time, never really looking at the absolute value. This means that even if there have been errors in the past, a proper monitoring solution will automatically ignore them, but restarts can still cause glitches if the monitor doesn't take the reset into account.
(Managed switches usually allow clearing the counters at least for display purposes, but might not clear the actual data so that monitoring software still works. E.g., as I recall, on HP switches clearing the counters on the command line only clears them for the current session. Disconnecting and logging back in shows the raw values again.)
| Are RX bytes and TX bytes of ifconfig since uptime or lifetime or something else? |
1,548,939,342,000 |
If I ssh directly ssh [email protected], the server behaves as normal and I can execute any number of commands before logging out.
The server IP address is very similar to one defined in my network settings, but with the last octet switched. The below command reads from ifconfig and generates the correct IP address.
ifconfig Netcon | grep "inet " | printf `awk '{ print $2 }'` | tail -c 1 | ssh -tt [email protected].`tr 12 21`
SSH prompts for the server password and logs in, showing the new hostname on my prompt. However, anything I enter does not get executed.
Last login: Fri Feb 28 09:07:38 2020 from 192.168.13.2
[email protected]:~$ ping google.com
cd
asdasdwjawdi
If I remove the -tt from the SSH call, the login fails with:
tput: No value for $TERM and no -T specified
|
You're mixing up stdin for the ssh command and the processing required to generate the final octet. Essentially your command is in this shape,
echo 1.2.3.4 | ssh -tt user@`tr 12 21`
From this I hope you can see that the tr is receiving input from the echo command (your pipeline) so isn't connected to your terminal. Furthermore the ssh is also trying to read its input from the pipe.
I think what you probably want is this,
ip=$(ifconfig eth0 | awk '/inet / { split($2, ip, /\./); printf "%d.%d.%d.2\n", ip[1], ip[2], ip[3] }')
ssh "user@$ip"
or on the one line without a temporary variable,
ssh "user@$(ifconfig eth0 | awk '/inet / { split($2, ip, /\./); printf "%d.%d.%d.2\n", ip[1], ip[2], ip[3] }')"
| Cannot execute commands after logging in to server over SSH when IP is generated by linux command |
1,548,939,342,000 |
I've been making a BASh script that changes your MAC Address to that of any manufacturer of your choice from a list. At the last part of the script that is run, it stops before finishing. Here is the code for that part:
function spoofUseMAC() {
echo
read -p "[*] $($stopAllFX; $bgBlack; $white)Enter the number code for manufacturer: >>> " num
echo "[-] Generating MAC Address"
num=$( expr $num - 1 )
declare -a array
while read -r; do
array+=( "$REPLY" )
done < addr.txt
end=$( for i in {1..6} ; do echo -n ${hexchars:$(( $RANDOM % 16 )):1} ; done | sed -e 's/\(..\)/:\1/g' )
macAddress=${array[$num]}$end
echo "[-] MAC Address generated !"
echo "[-] Using address: $macAddress"
$skyBlue; $bold; echo
ifconfig
$white
read -p "[*] $($stopAllFX; $bgBlack; $white)Select an interface: >>> " iface
$yellow; echo "[-] $iface selected !"
$white; echo "[-] Disabling $iface ..."
ifconfig $iface down
ifconfig '$iface' hw ether '$macAddress'
echo "[-] MAC Address spoofed !"
sleep 1
echo "[-] Enabling $iface ..."
ifconfig '$iface' up
echo "[-] $iface enabled !"
echo "[-] Using address: $macAddress"
exit
}
function spoofSearchAgainOrNot() {
$bold; $white; echo
echo "[*] $($stopAllFX; $bgBlack; $white)Please select an option from the list below:"
$yellow; $bold; echo " [$($white)0$($yellow)] $($stopAllFX; $bgBlack; $white)Search again"
$yellow; $bold; echo " [$($white)1$($yellow)] $($stopAllFX; $bgBlack; $white)Use one of these"
read -p ">>> " searchAgainOrNot
if [[ "$searchAgainOrNot" == "0" ]]; then
spoofSearch
elif [[ "$searchAgainOrNot" == "1" ]]; then
spoofUseMAC
else
spoofSearchAgainOrNot
fi
}
# Spoof, search option selected
function spoofSearch() {
$bold; echo
read -p "[*] $($stopAllFX; $bgBlack; $white)Search for a manufacturer: >>> " search
$blue; awk -F '#' '{printf("%10d %s\n", NR, ":" $1 )}' /usr/bin/oui.txt | grep -i $search
spoofSearchAgainOrNot
}
# Spoof
function spoof() {
echo; $white
echo "[*] $($stopAllFX; $bgBlack; $white)Please select an option from the list below:"
$yellow; $bold; echo " [$($white)0$($yellow)] $($stopAllFX; $bgBlack; $white)Search for a manufacturer"
$yellow; $bold; echo " [$($white)1$($yellow)] $($stopAllFX; $bgBlack; $white)Browse for a manufacturer through $($bold)long $($stopAllFX; $bgBlack; $white)list"
read -p ">>> " searchOrBrowse
if [[ $searchOrBrowse == "0" ]]; then
spoofSearch
elif [[ $searchOrBrowse == "1" ]]; then
spoofBrowse
else
spoof
fi
}
Why can't I use the internet (git clone says could not resolve hostname: github.com) after running this script? And why is it not finishing?
EDIT: This is supposed to work on MacOS and Linux. On MacOS, there is no ip route command, but in Linux, ip route results in:
192.168.0.0/24 dev wlp1s0 proto kernel scope link src 192.168.0.18
192.168.0.0/24 dev wlp1s0 proto kernel scope link src 192.168.0.18 metric 600
|
I found the problem: one of the $ifaces had quotes around it when it shouldn't have.
| Cannot connect to internet after changing MAC Address |
1,548,939,342,000 |
I want to configure my eth1 interface to have a static IP, even if the cable is not plugged in. Is that at all doable?
I need that as I want to eventually configure a DHCP server (isc-dhcp-server) to give an IP address to a device that will be connected to my machine via this interface. The device, however might not be plugged in all the time. And it seems like DHCP server will refuse to start if that interface doesn't have an IP/subnet. (please correct me if I am wrong).
My /etc/network/interfaces has the following entry for eth1:
iface eth1 inet static
address 192.168.20.1
netmask 255.255.255.0
gateway 192.168.20.1
Still when running ifconfig the eth1 doesn't have an IP assigned.
I was always completely ignorant in terms of networking etc, so I might be missing something very obvious.
Any help appreciated. Thanks.
|
You have to write before this:
auto eth1
iface eth1 inet static
address 192.168.20.1
netmask 255.255.255.0
gateway 192.168.20.1
| Configure static IP on eth1 |
1,548,939,342,000 |
When I already have an IPv4 address on interface and I try to add a second one with ifconfig eth0 192.168.8.1 netmask 255.255.255.0 up command, then my previous IP address is replaced. I can add second address with for example ifconfig eth0:test 192.168.10.1 netmask 255.255.255.0 up command. This creates so called alias. However, I could also add secondary IP address with ip addr add 192.168.12.0/24 dev eth0 command and this does not create alias:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 24:be:05:21:22:1e brd ff:ff:ff:ff:ff:ff
inet 192.168.8.1/24 brd 192.168.8.255 scope global eth0
valid_lft forever preferred_lft forever
inet 192.168.10.1/24 brd 192.168.10.255 scope global eth0:test
valid_lft forever preferred_lft forever
inet 192.168.12.0/24 scope global eth0
valid_lft forever preferred_lft forever
Are both configurations are exactly the same simply ip addr way doesn't create this unnecessary alias?
|
From ip-address(8):
It is possible to have several different addresses attached to one device.
These addresses are not discriminated, so that the term alias is not quite
appropriate for them and we do not use it in this document.
You can, however, emulate the deprecated “alias” functionality
using labels:
$ ip address add dev eth7 42.42.42.42/23 label eth7:foo
| Understanding network aliases in Linux |
1,548,939,342,000 |
Is there a way to find my type of router from the command line? My IP address is the standard 192.168.1.1 IP address.
|
You could use curl http://192.168.1.1 just to get the HTML of the login page. It probably says on it.
Also, you could use arp -a to get the MAC of the router, and then look up the first 6 digits to see what hardware vendor it is.
| Find type of router |
1,548,939,342,000 |
I am trying to get my CentOS v7 server to run IPv6. Root works, it can ping using "ping6 ipv6.google.com", and ifconfig looks great; I see the lines:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 149.202.217.90 netmask 255.255.255.0 broadcast 149.202.217.255
inet6 fe80::ec4:7aff:fec4:d912 prefixlen 64 scopeid 0x20<link>
inet6 2001:41d0:1000:1c5a:: prefixlen 64 scopeid 0x0<global>
But as an unprivileged user, I can't ping ipv6 and I don't see the inet6 addresses in ifconfig.
What is happening? Why can't my users see the same interfaces, setup in the same way as root?
[edit]
As requested, ip a s and ping6 -c1 ipv6.google.com output:
root
[root@rabbit ~]# ip a s
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 2001:41d0:1000:1c5a::/64 scope global
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN
link/ether 5e:63:58:37:5d:30 brd ff:ff:ff:ff:ff:ff
3: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN
link/ether 32:ad:47:94:1f:b1 brd ff:ff:ff:ff:ff:ff
4: ifb0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN qlen 32
link/ether 7e:52:08:a5:1a:dd brd ff:ff:ff:ff:ff:ff
5: ifb1: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN qlen 32
link/ether 3e:ba:b9:d1:09:3b brd ff:ff:ff:ff:ff:ff
6: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 0c:c4:7a:c4:d9:12 brd ff:ff:ff:ff:ff:ff
inet 149.202.217.90/24 brd 149.202.217.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 2001:41d0:1000:1c5a::/64 scope global
valid_lft forever preferred_lft forever
inet6 fe80::ec4:7aff:fec4:d912/64 scope link
valid_lft forever preferred_lft forever
7: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 0c:c4:7a:c4:d9:13 brd ff:ff:ff:ff:ff:ff
8: teql0: <NOARP> mtu 1500 qdisc noop state DOWN qlen 100
link/void
9: tunl0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN
link/ipip 0.0.0.0 brd 0.0.0.0
10: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN
link/sit 0.0.0.0 brd 0.0.0.0
11: ip6tnl0@NONE: <NOARP> mtu 1452 qdisc noop state DOWN
link/tunnel6 :: brd ::
[root@rabbit ~]# ping6 -c1 ipv6.google.com
PING ipv6.google.com(par03s15-in-x0e.1e100.net) 56 data bytes
64 bytes from par03s15-in-x0e.1e100.net: icmp_seq=1 ttl=57 time=6.61 ms
--- ipv6.google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 6.615/6.615/6.615/0.000 ms
user (pryormic)
[pryormic@rabbit ~]$ ip a s
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 2001:41d0:1000:1c5a::/64 scope global
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN
link/ether 5e:63:58:37:5d:30 brd ff:ff:ff:ff:ff:ff
3: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN
link/ether 32:ad:47:94:1f:b1 brd ff:ff:ff:ff:ff:ff
4: ifb0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN qlen 32
link/ether 7e:52:08:a5:1a:dd brd ff:ff:ff:ff:ff:ff
5: ifb1: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN qlen 32
link/ether 3e:ba:b9:d1:09:3b brd ff:ff:ff:ff:ff:ff
6: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 0c:c4:7a:c4:d9:12 brd ff:ff:ff:ff:ff:ff
inet 149.202.217.90/24 brd 149.202.217.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 2001:41d0:1000:1c5a::/64 scope global
valid_lft forever preferred_lft forever
inet6 fe80::ec4:7aff:fec4:d912/64 scope link
valid_lft forever preferred_lft forever
7: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 0c:c4:7a:c4:d9:13 brd ff:ff:ff:ff:ff:ff
8: teql0: <NOARP> mtu 1500 qdisc noop state DOWN qlen 100
link/void
9: tunl0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN
link/ipip 0.0.0.0 brd 0.0.0.0
10: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN
link/sit 0.0.0.0 brd 0.0.0.0
11: ip6tnl0@NONE: <NOARP> mtu 1452 qdisc noop state DOWN
link/tunnel6 :: brd ::
[pryormic@rabbit ~]$ ping6 -c1 ipv6.google.com
ping: icmp open socket: Operation not permitted
[edit2]
I've added ifconfig output below:
root
[root@rabbit ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 149.202.217.90 netmask 255.255.255.0 broadcast 149.202.217.255
inet6 fe80::ec4:7aff:fec4:d912 prefixlen 64 scopeid 0x20<link>
inet6 2001:41d0:1000:1c5a:: prefixlen 64 scopeid 0x0<global>
ether 0c:c4:7a:c4:d9:12 txqueuelen 1000 (Ethernet)
RX packets 12131475 bytes 2122218137 (1.9 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1113935 bytes 690582284 (658.5 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether 0c:c4:7a:c4:d9:13 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 6632 bytes 1169904 (1.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
inet6 2001:41d0:1000:1c5a:: prefixlen 64 scopeid 0x0<global>
loop txqueuelen 0 (Local Loopback)
RX packets 332704 bytes 448694222 (427.9 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 332704 bytes 448694222 (427.9 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
user (pryormic)
[pryormic@rabbit ~]$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 149.202.217.90 netmask 255.255.255.0 broadcast 149.202.217.255
ether 0c:c4:7a:c4:d9:12 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether 0c:c4:7a:c4:d9:13 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 0 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
The following command should give users the capability to use ping6. As root run
setcap cap_net_raw+ep /usr/bin/ping
| Unprivileged ping6 not working |
1,548,939,342,000 |
I have a linux box and has ethernet, wlan STA/client and wlan Access Point.
It's a internet connection via ethernet and I can log in to the box via ssh. But I wish to use the box like a wireless router and be able to connect to internet by using for example a smart phone. I can connect my phone to wifi but it has no internet access.
Here are my interfaces:
eth0 is Ethernet
eth1 and eth2 is WLAN
# ifconfig
br0 Link encap:Ethernet HWaddr 00:15:BC:22:17:20
inet addr:10.10.1.116 Bcast:10.10.1.255 Mask:255.255.255.0
inet6 addr: fe80::215:bcff:fe22:1720/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6377 errors:0 dropped:608 overruns:0 frame:0
TX packets:615 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:865911 (845.6 KiB) TX bytes:59751 (58.3 KiB)
eth0 Link encap:Ethernet HWaddr 00:15:BC:22:17:20
inet6 addr: fe80::215:bcff:fe22:1720/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6417 errors:0 dropped:6 overruns:0 frame:0
TX packets:623 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:985364 (962.2 KiB) TX bytes:60399 (58.9 KiB)
eth1 Link encap:Ethernet HWaddr 00:15:BC:22:17:21
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
eth2 Link encap:Ethernet HWaddr 02:15:BC:22:17:21
inet addr:192.168.2.10 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::15:bcff:fe22:1721/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:502 errors:0 dropped:3 overruns:0 frame:0
TX packets:236 errors:0 dropped:8 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:44998 (43.9 KiB) TX bytes:24874 (24.2 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:164 errors:0 dropped:0 overruns:0 frame:0
TX packets:164 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:13525 (13.2 KiB) TX bytes:13525 (13.2 Ki
B)
And here is /etc/network/interfaces file:
auto lo
iface lo inet loopback
iface eth0 inet manual
iface eth1 inet dhcp
iface eth2 inet dhcp
iface br0 inet dhcp
hostname gw-143A
bridged_ports eth0
Wireless:
# iwconfig
tap0 no wireless extensions.
lo no wireless extensions.
br0 no wireless extensions.
eth2 IEEE 802.11-bgn Mode:Master Frequency:2.457 GHz
eth1 IEEE 802.11-bgn ESSID:""
Mode:Managed Frequency:2.437 GHz Access Point: Not-Associated
Bit Rate:0 kb/s
RTS thr:off Fragment thr:off
Encryption key:9F64-0D78-CCAB-A8 [3]
Power Management:off
Link Quality:0 Signal level:0 Noise level:0
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
sit0 no wireless extensions.
eth0 no wireless extensions.
|
In order for your linux box to act as a WLAN access point, you will need to:
make sure your wireless NICs use a driver which supports AP. Output of lsmod | grep 80211 usually helps. If your driver doesn't support AP mode, you'll have to get a new WLAN adapter which does.
make sure your kernels supports IP forwarding and enable it. This is usually done by running echo 1 > /proc/sys/net/ipv4/ip_forward as root.
configure routing tables to forward network packets from br0 to eth2:
sudo iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE
sudo iptables -A FORWARD -i br0 -o eth2 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i eth2 -o br0 -j ACCEPT
install and configure an access point management software.
configure a DHCP server which would assign your phone an IP address, if this is not already done.
| WLAN connected but no internet access |
1,548,939,342,000 |
On a Solaris local zone, what is the default netmask?
I have a blank /etc/netmasks file, but if I run ifconfig I can see that the netmask is set to ffffff00 .
[username@servername]# /usr/sbin/ifconfig -a
lo0:10: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
ifname5:3: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 7
inet 10.56.20.179 netmask ffffff00 broadcast 10.56.20.255
How is the subnet mask set on a reboot if the netmasks file is blank?
Is this based on something in the global zone?
Similarly (??), where is the default subnet mask set if the ifconfig command is used to set the address for an interface and the netmask is not explicitly set in the command?
clarification I want to check the configured subnet mask for non-global zones based on static configuration files, for purpose of predicting behavior on reboot or failover. What file(s) has this information?
As schilly mentioned, the example I gave is probably not typical setup for 10.x.x.x network, but I think someone (more experienced than me) configured its settings on purpose and I am trying to make inventory of the network settings for all the non-global zones.
|
Depending on the zone and the solaris version you might have to specify the network in different ways.
Using shared network interface, the zone OS does not need to know about the network configuration because this is shared with the global zone. So in fact you networks will be defined in the global zone and you just specify the IP in the zonecfg configuration.
If you are using exclusive-IP (available on Solaris 11), then you need to configure manually the ip inside each zone as they have separate IP stack.
schily mentioned and quite well, that if a network mask is not specify it is taken from the defaults. If you look here you will find the following:
netmask mask
For IPv4 only. Specify how much of the address to reserve for subdividing networks into subnetworks. The mask includes the network part of the local address and the subnet part, which is taken from the host field of the address. The mask contains 1's for the bit positions in the 32-bit address which are to be used for the network and subnet parts, and 0's for the host part. The mask should contain at least the standard network portion, and the subnet field should be contiguous with the network portion. The mask can be specified in one of four ways:
with a single hexadecimal number with a leading 0x,
with a dot-notation address,
with a “+” (plus sign) address, or
with a pseudo host name/pseudo network name found in the network database networks(4).
If a “+” (plus sign) is given for the netmask value, the mask is looked up in the netmasks(4) database. This lookup finds the longest matching netmask in the database by starting with the interface's IPv4 address as the key and iteratively masking off more and more low order bits of the address. This iterative lookup ensures that the netmasks(4) database can be used to specify the netmasks when variable length subnetmasks are used within a network number.
If a pseudo host name/pseudo network name is supplied as the netmask value, netmask data may be located in the hosts or networks database. Names are looked up by first using gethostbyname(3NSL). If not found there, the names are looked up in getnetbyname(3SOCKET). These interfaces may in turn use nsswitch.conf(4) to determine what data store(s) to use to fetch the actual value.
For both inet and inet6, the same information conveyed by mask can be specified as a prefix_length attached to the address parameter.
Additionally,
If you are using shared address in the zone configuration and you configure an ip that is not recognized via zonecfg you will see the following message:
zone 'zone-shared-ip': warning: net0: no matching subnet found in netmasks(4): 10.0.2.150; using default of 255.0.0.0
| default netmask in Solaris |
1,548,939,342,000 |
I'm using ifconfig on OpenSUSE. When I run ifconfig eth0 I get
eth0 Link encap:Ethernet HWaddr CE:FD:75:DF:A5:6D
inet addr:172.16.4.177 Bcast:172.16.5.255 Mask:255.255.254.0
inet6 addr: fe80::adfd:75ef:fedf:v56d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11812456 errors:0 dropped:2 overruns:0 frame:0
TX packets:7000495 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2591436376 (2471.3 Mb) TX bytes:9196901478 (8770.8 Mb)
I'm looking to format this so each parameter gets returned on a new line using sed or awk e.g.:
eth0
Link encap:Ethernet
HWaddr CE:FD:75:DF:A5:6D
inet addr:172.16.4.177
Bcast:172.16.5.255
Mask:255.255.254.0
inet6 addr: fe80::adfd:75ef:fedf:v56d/64
Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500
Metric:1
RX packets:11812456
errors:0
dropped:2
overruns:0
frame:0
TX packets:7000495
errors:0
dropped:0
overruns:0
carrier:0
collisions:0
txqueuelen:1000
RX bytes:2591436376 (2471.3 Mb)
TX bytes:9196901478 (8770.8 Mb)
I've tried ifconfig eth0 | sed 's/ /\r/' but that doesn't seem to split on the double space.
|
You can start with
sed 's/\(:[^: ]\+\) \([^(]\)/\1\n\2/g;s/\()\)/\1\n/;s/^ \+//'
it should be close enough, and most probably can be simplified and optimized further.
The result:
eth0 Link encap:Ethernet
HWaddr CE:FD:75:DF:A5:6D
inet addr:172.16.4.177
Bcast:172.16.5.255
Mask:255.255.254.0
inet6 addr: fe80::adfd:75ef:fedf:v56d/64
Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500
Metric:1
RX packets:11812456
errors:0
dropped:2
overruns:0
frame:0
TX packets:7000495
errors:0
dropped:0
overruns:0
carrier:0
collisions:0
txqueuelen:1000
RX bytes:2591436376 (2471.3 Mb)
TX bytes:9196901478 (8770.8 Mb)
| Formatting ifconfig using sed/awk |
1,548,939,342,000 |
I can connect to the Internet without a problem by using wireless networks.
I have a DSL connection on defined which can connect to the Internet when LAN is connected. When I plug-in network cable, network-manager icon keeps waiting for address from LAN and connecting DSL does nothing. What should I do?
Output of ifconfig:
eth0 Link encap:Ethernet HWaddr 28:d2:44:ce:05:84
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:22 errors:0 dropped:2 overruns:0 frame:0
TX packets:45 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1320 (1.2 KiB) TX bytes:15390 (15.0 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:252 errors:0 dropped:0 overruns:0 frame:0
TX packets:252 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:18528 (18.0 KiB) TX bytes:18528 (18.0 KiB)
wlan0 Link encap:Ethernet HWaddr 30:10:b3:14:07:6b
inet addr:192.168.1.4 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::3210:b3ff:fe14:76b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5330 errors:0 dropped:0 overruns:0 frame:0
TX packets:5671 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3872796 (3.6 MiB) TX bytes:1117262 (1.0 MiB)
|
It looks like your cabled connection is not obtaining an IP address from the DSL connection.
This can be either because there is no DHCP server running on the network you are connecting to or because the interface is not properly configured.
Try doing the following:
Install the ifupdown-extra package, (as root): apt-get install ifupdown-extra
Disable the radio interface by using the hardware on/off radio switch.
Check if your LAN interface (eth0) obtains an IP address
If it does not, force it to obtain an IP address using dhcp: dhclient eth0
If the above does not work try to setup an IP address for your interface staticly running: ip addr add 192.168.1.15 dev eth0; ip route add default via 192.168.1.1
If step 4 or 5 works, test your network connection runnig network-test (tool provided by the ifupdown-extra package)
If network-manager was not able to configure your LAN interface (i.e. step 3 failed, but the others worked) maybe your system is not properly configured to make it manage interfaces. Review the following entry in the Debian Wiki: https://wiki.debian.org/NetworkManager and make sure your /etc/network/interfaces does not have any eth0 entry which would prevent it from working.
| Debian Jessie: My LAN is not working! |
1,548,939,342,000 |
There is a line in the output info of sudo ifconfig.
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
What kind of word type UP is? A verb?
It means enhance ,lift,raise?
Why write it as UPPING BROADCAST such as RUNNING MULTICAST?
Is RUNNING MULTICAST a phrase to modify BROADCAST?
dirkt is so kind to explain it in detail,the person who downgrade me would apologize for the action ,it is hard to fully understand many manual for a non-native english speaker.
It is not a joke to ask such kind of issue for a non-native english speaker.
|
All of these are flags; it's not a complete sentence. UP is actually a preposition, not a verb (not that it matters), in contrast to DOWN, and an interface is said to be up if it's enabled to transmit and receive network packets. By default, ifconfig only lists network interfaces that are up. You need to use ifconfig -a to also see interfaces that are down. (Or use the more modern ip instead of ipconfig in the first place).
You can also change the state of the interface from up to down, or vice versa, using ifconfig (or ip link).
In the same way, BROADCAST, MULTICAST and RUNNING are other flags that describe characteristics of the network interface (able to do broadcasts, able to do multicasts, etc.)
| up in UP BROADCAST RUNNING MULTICAST |
1,548,939,342,000 |
Running Ubuntu 22.04.3 LTS on top of WSL2
Output of ifconfig:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1492
inet 172.28.193.11 netmask 255.255.240.0 broadcast 172.28.207.255
inet6 fe80::215:5dff:fe3e:7ffa prefixlen 64 scopeid 0x20<link>
ether 00:15:5d:3e:7f:fa txqueuelen 1000 (Ethernet)
RX packets 1402 bytes 590609 (590.6 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 163 bytes 52446 (52.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Output of ipconfig /all from PowerShell (pardon my machine's French):
Configuration IP de Windows
Nom de l’hôte . . . . . . . . . . : Zenbook-OZ
Suffixe DNS principal . . . . . . :
Type de noeud. . . . . . . . . . : Hybride
Routage IP activé . . . . . . . . : Non
Proxy WINS activé . . . . . . . . : Non
Liste de recherche du suffixe DNS.: Speedport_W_724V_01011603_07_008
Carte réseau sans fil Connexion au réseau local* 1 :
Statut du média. . . . . . . . . . . . : Média déconnecté
Suffixe DNS propre à la connexion. . . :
Description. . . . . . . . . . . . . . : Microsoft Wi-Fi Direct Virtual Adapter
Adresse physique . . . . . . . . . . . : 3E-55-76-BE-66-95
DHCP activé. . . . . . . . . . . . . . : Oui
Configuration automatique activée. . . : Oui
Carte réseau sans fil Connexion au réseau local* 2 :
Statut du média. . . . . . . . . . . . : Média déconnecté
Suffixe DNS propre à la connexion. . . :
Description. . . . . . . . . . . . . . : Microsoft Wi-Fi Direct Virtual Adapter #2
Adresse physique . . . . . . . . . . . : 3E-55-76-BE-76-85
DHCP activé. . . . . . . . . . . . . . : Oui
Configuration automatique activée. . . : Oui
Carte réseau sans fil Wi-Fi :
Suffixe DNS propre à la connexion. . . : Speedport_W_724V_01011603_07_008
Description. . . . . . . . . . . . . . : MediaTek Wi-Fi 6E MT7922 (RZ616) 160MHz Wireless LAN Card
Adresse physique . . . . . . . . . . . : 3C-55-76-BE-46-B5
DHCP activé. . . . . . . . . . . . . . : Oui
Configuration automatique activée. . . : Oui
Adresse IPv6. . . . . . . . . . . . . .: 2003:c5:c715:bad9:aa0e:5e09:f399:6903(préféré)
Adresse IPv6 temporaire . . . . . . . .: 2003:c5:c715:bad9:fc98:b63c:31e6:1374(préféré)
Adresse IPv6. . . . . . . . . . . . . .: 2003:c5:c715:badb:904b:d90b:7543:f858(déprécié)
Adresse IPv6 de liaison locale. . . . .: fe80::f215:b016:e094:6711%13(préféré)
Adresse IPv4. . . . . . . . . . . . . .: 192.168.2.106(préféré)
Masque de sous-réseau. . . . . . . . . : 255.255.255.0
Bail obtenu. . . . . . . . . . . . . . : mercredi 13 mars 2024 01:52:12
Bail expirant. . . . . . . . . . . . . : jeudi 4 avril 2024 00:38:51
Passerelle par défaut. . . . . . . . . : fe80::1%13
192.168.2.1
Serveur DHCP . . . . . . . . . . . . . : 192.168.2.1
IAID DHCPv6 . . . . . . . . . . . : 121394550
DUID de client DHCPv6. . . . . . . . : 00-01-00-01-2C-2A-D6-E9-00-4C-E0-86-43-54
Serveurs DNS. . . . . . . . . . . . . : fe80::1%13
192.168.2.1
NetBIOS sur Tcpip. . . . . . . . . . . : Activé
Carte Ethernet Connexion réseau Bluetooth :
Statut du média. . . . . . . . . . . . : Média déconnecté
Suffixe DNS propre à la connexion. . . :
Description. . . . . . . . . . . . . . : Bluetooth Device (Personal Area Network)
Adresse physique . . . . . . . . . . . : 3C-55-76-BE-46-B6
DHCP activé. . . . . . . . . . . . . . : Oui
Configuration automatique activée. . . : Oui
Carte Ethernet vEthernet (WSL (Hyper-V firewall)) :
Suffixe DNS propre à la connexion. . . :
Description. . . . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter
Adresse physique . . . . . . . . . . . : 00-15-5D-AE-85-70
DHCP activé. . . . . . . . . . . . . . : Non
Configuration automatique activée. . . : Oui
Adresse IPv6 de liaison locale. . . . .: fe80::5516:60d0:65b2:eb67%35(préféré)
Adresse IPv4. . . . . . . . . . . . . .: 172.28.192.1(préféré)
Masque de sous-réseau. . . . . . . . . : 255.255.240.0
Passerelle par défaut. . . . . . . . . :
IAID DHCPv6 . . . . . . . . . . . : 587208029
DUID de client DHCPv6. . . . . . . . : 00-01-00-01-2C-2A-D6-E9-00-4C-E0-86-43-54
NetBIOS sur Tcpip. . . . . . . . . . . : Activé
My question:
I don't understand where the IP address 172.28.193.11 (assigned to eth0 in the output ifconfig) comes from.
The MAC address 00:15:5d:3e:7f:fa associated to eth0 in ifconfig does not appear anywhere in the output of ipconfig /all on PowerShell.
To what network interface does the MAC address 00:15:5d:3e:7f:fa correspond?
|
A few notes, starting with the suggestion to use the ip command and its subcommands. This replaces the deprecated ifconfig command. I'll use ip commands for any examples in this answer.
As mentioned in the other answer, WSL2 by default Footnote uses a virtual network interface. As for "where the ... address ... comes from", there's a Hyper-V virtual switch that interfaces between WSL and your computer.
You can see that virtual switch if you have both Windows Professional (or higher) and the Hyper-V Manager feature installed, by selecting the Virtual Switch Manager... action in the right-hand pane. However, I generally recommend you not make any modifications to it unless you are really certain you have the expertise.
That virtual switch also handed out the IP address you see for the WSL (Hyper-V firewall) interface in your ifconfig output.
In WSL, run ip route to show that the traffic is routing to the IP address of the WSL switch in Windows. In your output, that was 172.28.192.1, so you should see:
$ ip route
default via 172.28.192.1 dev eth0 proto kernel
Footnote: Mirrored Mode
The (WSL (Hyper-V firewall)) in your ipconfig output in Windows tells me that you are running a fairly recent release of WSL2 that includes a new networking mode.
As mentioned above, the default networking mode in WSL2 is NAT. Up until fairly recently (September 2023), this was the only networking mode available to WSL2. However, release 2.0.0 of WSL2 brought several new "experimental" features, including "Mirrored" networking mode, where Windows network interfaces are mirrored into WSL2 instead of being NAT'd. That feature has been promoted, and is no longer experimental in the latest production WSL2 release.
If you were to have Mirrored mode enabled in your .wslconfig, then the IP addresses and interfaces you see with ifconfig/ip addr would generally match up with what you see in the Windows ipconfig /all command.
| Machine MAC address with Ubuntu on top of WSL2 |
1,548,939,342,000 |
My MAC address is not showing in kali linux using the ifconfig command. There is no option for Hwr inside wlan0 which should contain the MAC address
how do I find my MAC address?
|
ip addr will do it, ifconfig is obsolete.
| Mac address not showing in ifconfig [closed] |
1,548,939,342,000 |
On a device with Debian 10, I want to make a permanent change to the IP via modifying /etc/network/interfaces . Hence, I modify it as follows :
auto lo
iface lo inet loopback
auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 192.168.109.11
netmask 255.255.255.0
gateway 192.168.109.254
and after that I perform the following :
ifdown eth0 && ifup eth0
but at this point it returns the following error :
root@var-som-mx6:~# ifdown eth0 && ifup eth0 --verbose
ifdown: interface eth0 not configured
ifup: configuring interface eth0=eth0 (inet)
/bin/run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
run-parts: executing /etc/network/if-pre-up.d/hostapd
run-parts: executing /etc/network/if-pre-up.d/wpasupplicant
/sbin/ip addr add 192.168.109.12/255.255.255.0 broadcast 192.168.109.255 dev eth0 label eth0
/sbin/ip link set dev eth0 up
/sbin/ip route add default via 192.168.109.254 dev eth0 onlink
RTNETLINK answers: Invalid argument
ifup: failed to bring up eth0
ifconfig tells me the following :
root@var-som-mx6:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.109.11 netmask 255.255.255.0 broadcast 192.168.109.255
inet6 fe80::fadc:7aff:fe3e:8dbb prefixlen 64 scopeid 0x20<link>
ether f8:dc:7a:3e:8d:bb txqueuelen 1000 (Ethernet)
RX packets 35999 bytes 8217478 (7.8 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 5137 bytes 1559379 (1.4 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Local Loopback)
RX packets 2837 bytes 258173 (252.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2837 bytes 258173 (252.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
What am I doing wrong?
|
ifdown and ifup seem to be not the best way to operate on network interfaces due to lots of pseudo-errors with RTNETLINK (Linux routing socket) that will go away only via system reboot, which may not be ideal.
IMHO, main way to handle this is via ifconfig commands (please also consider that ifconfig is deprecated and is replaced by the ip command) :
root@var-som-mx6:~# ifconfig eth0 down
** now, update /etc/network/interfaces.. **
root@var-som-mx6:~# ifconfig eth0 up 192.168.109.11 netmask 255.255.255.0
root@var-som-mx6:~# route add default gw 192.168.109.254
Note that you should update the /etc/network/interfaces after the ifconfig eth0 down
BTW, if you got your reasons to use ifdown and ifup, you can solve this as following :
root@var-som-mx6:~# ifdown --force eth0
** now, update /etc/network/interfaces.. **
root@var-som-mx6:~# ifup --force eth0
root@var-som-mx6:~# route add default gw 192.168.109.254
where --force will force configuration or deconfiguration of the interface (source), in particular :
The program keeps records of whether network interfaces are up or down. Under exceptional circumstances these records can become inconsistent with the real states of the interfaces. For example, an interface that was brought up using ifup and later deconfigured using ifconfig will still be recorded as up. To fix this you can use the --force option to force ifup or ifdown to run configuration or deconfiguration commands despite what it considers the current state of the interface to be.
If you also prefer to have all in one command line, the correct one-liner is the following :
root@var-som-mx6:~# ifdown eth0 --force && ip addr flush dev eth0 && route add default gw 192.168.109.254 && ifup eth0 --force
where ip addr flush dev eth0 is crucial.
This solutions solve also the "RTNETLINK answers: File exists" error.
| 'RTNETLINK answers: Invalid argument' after ifup ethX |
1,513,075,304,000 |
I need to put the IP of my VPS machine into a variable. I mean to the external IP address appearing the value of inet addr section, in ifconfig output.
I've tried:
ipa="$(hostname -i)"
But echo ${ipa} brought the localhost token: 127.0.1.1, so I looked for other solutions and all I found includes many pipes and awk operations which I know nothing about (never used awk and I'm not very familiar with regex).
I tried this:
ipa=$(ifconfig | grep "inet addr:[0-999]\.[0-999]\.[0-999]\.[0-999]")
But it failed given that echo ${ipa} has an empty line of output.
Why did what I've tried failed or at least how would you solve it?
|
ipa=$(ifconfig | perl -lane '/inet addr:(\S+)/ and $1 !~ "^127" and print $1')
Also see here for a plethora of alternatives.
E.g. using grep:
ipa=$(ifconfig | grep -Po 'inet addr:\K[^\s]+' | grep -v '^127')
Explanation:
ipa=$( ) assign the output of the command in parentheses to the variable ipa
ifconfig show interfaces and their addresses. You might prefer ip address
| grep -Po 'inet addr:\K[^\s]+' filter output using a perl-compatible regex, print the matched text
| grep -v '^127' filter again, this time excluding (-v) values that start (^) with 127
To get my external ip, I usually do:
dig +short myip.opendns.com @resolver1.opendns.com
| Putting external IP into a variable - grep operation failed [duplicate] |
1,513,075,304,000 |
I've always had the compulsion of checking man page for system-specific usages, and the one for ifconfig on Ubuntu Kylin is just too confusing.
What I'm trying to do is to add additional IPv4 addresses to my virtual machine Ethernet interface, where as the man page for the add subcommand says:
add address/prefixlen
Add an IPv6 address to an interface.
I suppose this cannot be the only problem with net-tools man page on Linux. So I want to know:
Where is the updated net-tools maintained? By each distribution or some specific someone else?
Where can one find the up-to-date documents for net-tools?
|
Here is the page of the net-tools project:
http://net-tools.sourceforge.net/
It includes documentation for all of the commands in the net-tools package. Here is the man-page for ifconfig:
http://net-tools.sourceforge.net/man/ifconfig.8.html
In order to add an additional IPv4 address to a network interface you would use a command such as the following:
ifconfig interface address
For example, in order to assign the address 192.168.1.1 to the eth0 interface you would run:
ifconfig eth0 192.168.1.1
Typically you would also supply a network mask corresponding to the desired subnetwork, e.g.:
ifconfig eth0 192.168.1.1 netmask 255.255.255.0
Also note that net-tools is widely considered to be deprecated. Most people recommend using the iproute2 suite instead. For further discussion on the state of net-tools see the following ServerFault post:
Where is the statement of deprecation of ifconfig (on linux)?
| Updated man page for ifconfig in GNU/Linux systems. |
1,513,075,304,000 |
This is my /etc/network/interfaces file:
auto bond0
iface bond0 inet manual
address 10.66.7.11/24
gateway 10.66.7.1
bond-mode 802.3ad
bond-slaves eth2 eth3
bond-miimon 100
bond-downdelay 200
bond-updelay 400
bond-lacp-rate 1
up ifconfig bond0 10.66.7.11/24 up
when I bring the bond0 interface up, it works, but the default gateway is not set
# route -n
Destination Gateway Genmask Flags Metric Ref Use Iface
10.66.7.0 0.0.0.0 255.255.255.0 U 0 0 0 bond0
I have to set the default gateway manually, and then everything works fine:
route add default gw 10.66.7.1 bond0
#route -n
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.66.7.1 0.0.0.0 UG 0 0 0 bond0
10.66.7.0 0.0.0.0 255.255.255.0 U 0 0 0 bond0
why is my default gateway not set automatically, when I have it defined in the /etc/network/interfaces file ?
|
Among multiple ifupdown implementations, I'll consider it's ifupdown (implementation "v1") and the interfaces(5) configuration as seen on Debian.
The bond0 stanza should not use the keyword manual:
The manual Method
This method may be used to define interfaces for which no
configuration is done by default. Such interfaces can be configured
manually by means of up and down commands or /etc/network/if-*.d
scripts.
which will configure bond0's bond properties (on Debian probably through the ifenslave package which adds plugin scripts in /etc/network/if-*.d) but not IP properties.
So nothing is done: both address and gateway options are ignored but manual commands brought through up scripts are executed, such as:
up ifconfig bond0 10.66.7.11/24 up
which manually runs a command which happens to be adding an address on bond0: that's why bond0 has an address, the LAN route automatically added by the kernel from this address, and no gateway.
The keyword static (which will still do what the manual method would do but will also configure IPv4 with inet static) should have been used:
The static Method
This method may be used to define Ethernet interfaces with statically
allocated IPv4 addresses.
to have ifupdown configure IP addresses and the default gateway on it.
So simply replace manual with static and remove the non-needed up entry. The configuration should then be:
auto bond0
iface bond0 inet static
address 10.66.7.11/24
gateway 10.66.7.1
bond-mode 802.3ad
bond-slaves eth2 eth3
bond-miimon 100
bond-downdelay 200
bond-updelay 400
bond-lacp-rate 1
| default gateway not set when using bond0 interface |
1,513,075,304,000 |
From https://networkengineering.stackexchange.com/questions/57935/is-a-network-interface-supposed-to-have-no-more-than-one-mac-address/57937?noredirect=1#comment100988_57937
A network interface in a MAC-based network always requires a MAC address, virtual or physical. However, there are networks that are not MAC-based.
Doesifconfig show lo as a virtual network interface? ifconfig doesn't show its MAC address, does it mean lo has no MAC address, and the network of loopback IP addresses is not MAC-based?
Thanks.
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 2403613 bytes 138542051 (138.5 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2403613 bytes 138542051 (138.5 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
Since the lo interface is not associated with a hardware network interface (it's a virtual loopback interface), it does not have an Ethernet hardware address (MAC address).
Communication though the loopback interface is not MAC-based. No routing needs to take place to send packets between NICs.
| Does `lo` have no MAC address? |
1,513,075,304,000 |
In my Redhat 7 Linux machine I see - RX errors 413556 and after some time I see the same error value - 413556 ( not increasing ).
First question - is it possible to know when this error triggered?
In case value is not increasing, can we say that network is healthy for now?
eop1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 104.19.8.21 netmask 255.255.255.0 broadcast 104.19.8.255
ether 12:7a:1a:60:2e:e9 txqueuelen 1000 (Ethernet)
RX packets 4064026662 bytes 2422841475170 (2.2 TiB)
RX errors 413556 dropped 49020 overruns 1537 frame 412019
TX packets 3341156925 bytes 3692324143458 (3.3 TiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 90 memory 0x96000000-967fffff
|
This number is simply a count of the number of errors that have occurred since the network interface was brought into the 'up' state. It's mostly useful for monitoring trends. Since it's not increasing, you can assume that the network was experiencing problems previously, but is currently working fine.
To further debug the state of the interface, you might want to try putting some traffic on it, such as downloading a large file using the curl or wget command, and polling the interface using the ifconfig command to see if the number stays still, or starts increasing. If you see it increasing, then there's something wrong with either the physical network card, or the driver software that's allowing it to operate through the OS.
Here's a handy command to try downloading a relatively small file. This command will dump the output to /dev/null so there isn't any residual file to delete once you're done with your debugging effort.
$ wget -O /dev/null http://speedtest.wdc01.softlayer.com/downloads/test10.zip
References
How to Test Your Internet Speed with a Terminal Command
| Errors from ifconfig? |
1,513,075,304,000 |
In my RHEL 7 minimal installation with Virtualization profile I found that interfaces configured with network manager(s) contain BROWSER_ONLY=no option, which is always set to no by default. Server is currently offline, so I won't post entire config, but this is from "regular", physical WAN facing interface enp5s0 (eth0). When i configured another physical NIC using nmtui, the same option appeared. I've seen it in many config files posted online.
Now, if I don't know it, then probably I don't need it. Of course that's not the case, this is purely out of curiosity. Does the name literally mean "this interface is only for web browser-related traffic"? I can see how that would make sense with dedicated physical card, possibly VPN/IPSEC, meant only for safe browsing, maybe online banking, stock exchange(sic.), finance.
Research:
all duckduckgo searches return content of ifcfg-* files that contain this option by default set to "no". I've tried searching for a phrase "BROWSER_ONLY=yes" to no avail
neither of IFCFG(8), IP(8), NETWORKS(5) man pages reveal that information
/usr/share/doc/initscripts-*/sysconfig.txt describes most of the options that go into ifcfg-* files for different types of connection, however there's no mention of BROWSER_ONLY
briefly browsed through http://linux-ip.net/ that contains IP Command reference ip-cref.ps, to which man ifcfg refers and which I didn't find on my system
and of course here, on Stack Exchange
grep -R BROWSER /usr/share/doc/*, info --apropos=BROWSER_ONLY - guess what...
haven't tried changing it to yes yet, however I doubt to see any difference, unless the interface will stop working altogether
Does it mean absolutely no one is using it? Is it some hidden or reserved for future use option?
I'm torn between posting this question in Unix&Linux and Server Fault. Not sure where it fits better.
|
I found NetworkManager docs that suggests this setting is only used if you also configure proxy settings, i.e. you have PROXY_METHOD=auto present, and then determines whether the proxy settings are for everything of just browsers, however they think they can distinguish that. The default is no already.
| What is BROWSER_ONLY option in ifcfg-* network configuration files? |
1,513,075,304,000 |
I'm looking for a way to bring down all other devices except the given one.
I think it would be along the lines of greping the ifconfig output to then pull all the device names except the specified one and then use those names as input to an ifconfig $DEV down command.
|
The ifconfig is deprecated, use ip instead.
You can use this simple script:
#!/bin/bash
if [ -z "$1" ]
then
echo "Device parameter missing!"
exit 1
fi
devices=`ip a | grep UP | cut -d " " -f2 | tr -d ":" | grep -v "lo" | grep -v "$1"`
for dev in $devices
do
ifdown $dev
done
It is called as:
./script.sh <device>
For example with eth0:
./script.sh eth0
If called without parameter, reports Device parameter missing!.
| How to bring down all internet devices except the specified one? |
1,513,075,304,000 |
So some genius changed the way this is printed. On the Raspberry with Raspbian (Debian Jessie):
$ /sbin/ifconfig eth0
eth0 Link encap:Ethernet HWaddr b8:27:eb:71:d5:56
inet addr:192.168.0.11 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::1e43:2c74:e7d6:6419/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:165 errors:0 dropped:0 overruns:0 frame:0
TX packets:135 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:17459 (17.0 KiB) TX bytes:18391 (17.9 KiB)
On my laptop (Debian Stretch):
$ /sbin/ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.77 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::39db:8c13:722f:b088 prefixlen 64 scopeid 0x20<link>
ether 40:b0:34:96:d9:02 txqueuelen 1000 (Ethernet)
RX packets 118126 bytes 23261567 (22.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 319445 bytes 452933203 (431.9 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 16 memory 0xcc200000-cc220000
I had code that parses for "inet addr:", this obviously fails now on the laptop. Is there a unique way to get, using a shell command, the eth0 IP address on both Raspbian/Jessie and Stretch?
|
This is identically formatted on both systems:
$ ip a show eth0 # stretch
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 40:b0:34:96:d9:02 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.77/24 brd 192.168.0.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::39db:8c13:722f:b088/64 scope link tentative
valid_lft forever preferred_lft forever
$ ip a show eth0 # raspbian jessie
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether b8:27:eb:71:d5:56 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.11/24 brd 192.168.0.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::1e43:2c74:e7d6:6419/64 scope link
valid_lft forever preferred_lft forever
| Stable command to parse eth0 IP on jessie and stretch |
1,513,075,304,000 |
I installed the drivers of this device and it works
iwconfig
here i got:
wlan1 unassociated Nickname:"<WIFI@REALTEK>"
Mode:Managed Frequency=2.412 GHz Access Point: Not-Associated
Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
Link Quality:0 Signal level:0 Noise level:0
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
but i can't switch it to "monitor mode":
ifconfig wlan1 down
iwconfig wlan1 mode monitor
i got an error:
Error for wireless request "Set Mode" (8B06) :
SET failed on device wlan1 ; Invalid argument.
TL-WN821N 's chip : Realtek RTL8192EU. I'm wondering if it doesn't support "monitor mode" ?
|
You can verify if your wifi card support the monitor mode through the iw command.
There is an example:
iw list | grep "Supported interface modes" -A10
sample output ( the monitor mode is supported ) :
Supported interface modes:
* IBSS
* managed
* AP
* AP/VLAN
* WDS
* monitor
* mesh point
* P2P-client
* P2P-GO
* outside context of a BSS
| External wifi adapter (TL-WN821N) can't turn to monitor mode |
1,513,075,304,000 |
I have this command line, but it's doubling the grep and awk
ifconfig eth1 2> /dev/null | grep "inet " | awk '{gsub("addr:","",$2); print $2 }' ||
ifconfig eth0 2> /dev/null | grep "inet " | awk '{gsub("addr:","",$2); print $2 }'`
I have being trying to shorten this by doing something like,
echo $(ifconfig eth1 2> /dev/null || ifconfig eth0 2> /dev/null) &> grep "inet " |
awk '{gsub("addr:","",$2); print $2 }'
but it returns nothing at all when I am looking to get the IP of server. What is the best way to say get info if on error try this and then pipe it to grep
|
Try this:
$ ( ifconfig eth2 2>/dev/null || ifconfig eth0 2>/dev/null ) | grep ...
It has the same logic, but it does the || inside the parens so it only passes the output of the successful command to grep.
| optimize command with or and pipe to parse the output of ifconfig |
1,513,075,304,000 |
I'm trying to install vicibox, an OpenSUSE distro which includes Asterisk. The fine manual says to set a static ip address with yast lan.
What's the difference between:
││[ ] Change Hostname via DHCP ││
││[x] Assign Hostname to Loopback IP
I have my hostname set:
YaST2 - lan @ arrakis
Network Settings
┌Global Options──Overview──Hostname/DNS──Routing──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│┌Hostname and Domain Name───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐│
││Hostname Domain Name ││
││arrakis▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ bounceme.net▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ││
││[ ] Change Hostname via DHCP ││
││[x] Assign Hostname to Loopback IP ││
│└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘│
│Modify DNS configuration Custom Policy Rule │
│Use Default Policy▒▒▒▒▒↓ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒↓ │
│┌Name Servers and Domain Search List────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐│
││Name Server 1 ┌Domain Search──────────────────────────────────────────────────────────────────────┐││
││8.8.8.8▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │google.com │││
││Name Server 2 │ │││
││8.8.4.4▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │ │││
││Name Server 3 │ │││
││▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ └───────────────────────────────────────────────────────────────────────────────────┘││
│└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘│
│ │
│ │
│
with good connectivity:
arrakis:~ #
arrakis:~ # uname -a
Linux arrakis 3.11.10-21-default #1 SMP Mon Jul 21 15:28:46 UTC 2014 (9a9565d) x86_64 x86_64 x86_64 GNU/Linux
arrakis:~ #
arrakis:~ # cat /etc/hosts
#
# hosts This file describes a number of hostname-to-address
# mappings for the TCP/IP subsystem. It is mostly
# used at boot time, when no name servers are running.
# On small systems, this file can be used instead of a
# "named" name server.
# Syntax:
#
# IP-Address Full-Qualified-Hostname Short-Hostname
#
127.0.0.1 localhost
# special IPv6 addresses
::1 localhost ipv6-localhost ipv6-loopback
fe00::0 ipv6-localnet
ff00::0 ipv6-mcastprefix
ff02::1 ipv6-allnodes
ff02::2 ipv6-allrouters
ff02::3 ipv6-allhosts
127.0.0.2 arrakis.bounceme.net arrakis
arrakis:~ #
arrakis:~ # hostname
arrakis
arrakis:~ #
arrakis:~ # ping arrakis.bounceme.net
PING arrakis.bounceme.net (127.0.0.2) 56(84) bytes of data.
64 bytes from arrakis.bounceme.net (127.0.0.2): icmp_seq=1 ttl=64 time=0.040 ms
64 bytes from arrakis.bounceme.net (127.0.0.2): icmp_seq=2 ttl=64 time=0.050 ms
64 bytes from arrakis.bounceme.net (127.0.0.2): icmp_seq=3 ttl=64 time=0.049 ms
^C
--- arrakis.bounceme.net ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1998ms
rtt min/avg/max/mdev = 0.040/0.046/0.050/0.007 ms
arrakis:~ #
arrakis:~ #
arrakis:~ # ping arrakis
PING arrakis.bounceme.net (127.0.0.2) 56(84) bytes of data.
64 bytes from arrakis.bounceme.net (127.0.0.2): icmp_seq=1 ttl=64 time=0.036 ms
64 bytes from arrakis.bounceme.net (127.0.0.2): icmp_seq=2 ttl=64 time=0.041 ms
64 bytes from arrakis.bounceme.net (127.0.0.2): icmp_seq=3 ttl=64 time=0.041 ms
c64 bytes from arrakis.bounceme.net (127.0.0.2): icmp_seq=4 ttl=64 time=0.040 ms
64 bytes from arrakis.bounceme.net (127.0.0.2): icmp_seq=5 ttl=64 time=0.043 ms
^C
--- arrakis.bounceme.net ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 3996ms
rtt min/avg/max/mdev = 0.036/0.040/0.043/0.004 ms
arrakis:~ #
arrakis:~ #
arrakis:~ # ifconfig
enp5s0 Link encap:Ethernet HWaddr 50:E5:49:C2:C8:05
inet addr:192.168.0.21 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::52e5:49ff:fec2:c805/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2632 errors:0 dropped:0 overruns:0 frame:0
TX packets:278 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:173852 (169.7 Kb) TX bytes:38509 (37.6 Kb)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:40 errors:0 dropped:0 overruns:0 frame:0
TX packets:40 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3248 (3.1 Kb) TX bytes:3248 (3.1 Kb)
arrakis:~ #
but want to set the ip address to static:
YaST2 - lan @ arrakis
Network Card Setup
┌General──Address──Hardware───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Device Type Configuration Name │
│ Ethernet▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒↓ enp5s0▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │
│( ) No Link and IP Setup (Bonding Slaves) [ ] Use iBFT values │
│( ) Dynamic Address DHCP▒▒▒▒▒▒▒▒▒▒↓ DHCP both version 4 and 6▒↓ │
│(x) Statically assigned IP Address │
│IP Address Subnet Mask Hostname │
│192.168.0.21▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ 255.255.255.0▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ arrakis.bounceme.net▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │
│┌Additional Addresses───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐│
││ ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ ││
││ │Alias Name│IP Address│Netmask │ ││
││ │ │ ││
││ │ │ ││
││ │
yet, as soon as I do so, I lose connectivity:
arrakis:~ # yast lan
arrakis:~ #
arrakis:~ #
arrakis:~ # ifconfig
enp5s0 Link encap:Ethernet HWaddr 50:E5:49:C2:C8:05
inet addr:192.168.0.21 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::52e5:49ff:fec2:c805/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4027 errors:0 dropped:0 overruns:0 frame:0
TX packets:858 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:271734 (265.3 Kb) TX bytes:265009 (258.7 Kb)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:40 errors:0 dropped:0 overruns:0 frame:0
TX packets:40 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3248 (3.1 Kb) TX bytes:3248 (3.1 Kb)
arrakis:~ #
arrakis:~ #
arrakis:~ # ping google.com
ping: unknown host google.com
arrakis:~ #
why can't I ping Google?
See also:
http://www.vicidial.org/VICIDIALforum/viewtopic.php?f=4&t=34261
----------------------------------------------------------------update
after changing to a static ip address. It's the same ip address as when dynamic.
With static ip:
arrakis:~ #
arrakis:~ # ifconfig
enp5s0 Link encap:Ethernet HWaddr 50:E5:49:C2:C8:05
inet addr:192.168.0.21 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::52e5:49ff:fec2:c805/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:10438 errors:0 dropped:0 overruns:0 frame:0
TX packets:1133 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:671095 (655.3 Kb) TX bytes:300227 (293.1 Kb)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:40 errors:0 dropped:0 overruns:0 frame:0
TX packets:40 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3248 (3.1 Kb) TX bytes:3248 (3.1 Kb)
arrakis:~ #
arrakis:~ # ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp5s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 50:e5:49:c2:c8:05 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.21/24 brd 192.168.0.255 scope global enp5s0
valid_lft forever preferred_lft forever
inet6 fe80::52e5:49ff:fec2:c805/64 scope link
valid_lft forever preferred_lft forever
arrakis:~ #
arrakis:~ # ip route
127.0.0.0/8 dev lo scope link
192.168.0.0/24 dev enp5s0 proto kernel scope link src 192.168.0.21
arrakis:~ #
arrakis:~ # ping www.google.com
ping: unknown host www.google.com
arrakis:~ #
arrakis:~ # yast lan
arrakis:~ #
and then, switching back to DHCP should, I would think, restore an ability to ping google:
arrakis:~ #
arrakis:~ # ping www.google.com
ping: unknown host www.google.com
arrakis:~ #
arrakis:~ # ip route
127.0.0.0/8 dev lo scope link
192.168.0.0/24 dev enp5s0 proto kernel scope link src 192.168.0.21
arrakis:~ #
arrakis:~ # ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp5s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 50:e5:49:c2:c8:05 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.21/24 brd 192.168.0.255 scope global enp5s0
valid_lft forever preferred_lft forever
inet6 fe80::52e5:49ff:fec2:c805/64 scope link
valid_lft forever preferred_lft forever
arrakis:~ #
arrakis:~ # ifconfig
enp5s0 Link encap:Ethernet HWaddr 50:E5:49:C2:C8:05
inet addr:192.168.0.21 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::52e5:49ff:fec2:c805/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11178 errors:0 dropped:0 overruns:0 frame:0
TX packets:1490 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:723997 (707.0 Kb) TX bytes:415085 (405.3 Kb)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:40 errors:0 dropped:0 overruns:0 frame:0
TX packets:40 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3248 (3.1 Kb) TX bytes:3248 (3.1 Kb)
arrakis:~ #
apparently not..
|
From your output:
arrakis:~ # ip route
127.0.0.0/8 dev lo scope link
192.168.0.0/24 dev enp5s0 proto kernel scope link src 192.168.0.21
arrakis:~ #
You don't have a default route. So you can only reach things on 127.0.0.0/8 (localhost) or 192.168.0.0/24 (the local subnet).
Add a default route and you should be good to go.
| why can't I ping Google with a static IP address? |
1,513,075,304,000 |
On runnning ifconfig command I get the following as output. I need the IP address of eth1 for running my python server port with.
eth0 Link encap:Ethernet HWaddr 08:00:27:CE:08:3D
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fece:83d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2474 errors:0 dropped:0 overruns:0 frame:0
TX packets:1511 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:204674 (199.8 KiB) TX bytes:158605 (154.8 KiB)
eth1 Link encap:Ethernet HWaddr 08:00:27:18:CF:85
inet6 addr: **fe80::a00:27ff:fe18:cf85/64** Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:20998 errors:0 dropped:0 overruns:0 frame:0
TX packets:42 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1648690 (1.5 MiB) TX bytes:10524 (10.2 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
venet0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet6 addr: fe80::1/128 Scope:Link
UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1
RX packets:5 errors:0 dropped:0 overruns:0 frame:0
TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:340 (340.0 b) TX bytes:515 (515.0 b)
inet6 addr: fe80::a00:27ff:fe18:cf85/64 for eth1 is not in standard IP addres format. What do I do to get the IP address of eth1
edit 1:
Result of the ip command:
[root@localhost config]# ip a l dev eth1
eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:18:cf:85 brd ff:ff:ff:ff:ff:ff
inet6 fe80::a00:27ff:fe18:cf85/64 scope link
valid_lft forever preferred_lft forever
|
fe80::/64 is a ipv6 address reserved to Link-local. ip a l dev eth1 should be enough to show your ip address on this specific interface(if assigned or acquired through a dhcp-server).
Worth reading:
Why is fe80::/10 reserved for link local addresses when fe80::/64 is actually used?
Where is the statement of deprecation of ifconfig (on linux)? - best answer
IPv6 address
| Not able to resolve IP address for eth1 in Vagrant VM |
1,513,075,304,000 |
I'm using centOS 6.3 on virtualbox as guest OS on Win 7 host. My problem is when I use ifconfig command in terminal, I'm being thrown internal IP address(10.x.x.x). However, when I googled "my IP address" I got my actual IP address. The same thing happens when I type ipconfig in DOS prompt. Is there a way to get external IP address in those places?
|
What you describe as your "actual" IP address isn't, it is the IP address of your router, or anything else that got an IP address from your provider and acts as an intermediary for your computer to the internet. That is why your (windows) hosts provides an internal address as well.
Your VirtualBox host gives out IP addresses in the range 10.x.x.x by default and acts as another intermediary.
To get the external IP assigned to your router, you can use:
curl icanhazip.com
But be aware that such services can go out of business without notice. If that is a problem, setup a service yourself on a public server you have access to, or interface with your router to get its public IP address.
| ifconfig command showing internal ip address |
1,513,075,304,000 |
How do you get only hardware interfaces
Tried:
ifconfig -a
ip link show
How do you get only local hardware interfaces using ifconfig/ip link show?
Like from my ifconfig I get(removed a lot):
en0: inet 192.168.0.146 netmask 0xffffff00 broadcast 192.168.0.255
utun0:
utun1:
utun2:
utun3:
utun4:
Update: I guess it is interfaces from previous Software Interface connections.
Then I investigated on the interface utun with lsof:
sudo lsof | grep utun
identitys 577
identitys 577
identitys 577
identitys 577
identitys 577
Ok something called identitys, still thinking it is local to my computer until I found nmap tool:
sudo nmap -sn 192.168.0.127/24
Nmap scan report for 192.168.0.6
Host is up (0.13s latency).
MAC Address: <xx:xx:xx:xx:xx:xx> (Sonos)
... # And more
Turns out it is my Sonos speakers on the local Wifi network.
Why is ipconfig/if link show showing other Interfaces?
Thanks
|
-You can try using awk like this way!
ifconfig | awk '{print $1"\t"$7}' | grep eth0
or this another way...
ifconfig | awk '{print $1"\t"$7}'|grep eth0|awk '{print $2}'
| ifconfig/ip link show- how to get only Hardware interface |
1,513,075,304,000 |
I am trying to set up communication between my laptop computer, running Ubuntu 20.04.2 LTS, and an Ettus Research USRP N210. I have been consulting the following resources:
https://files.ettus.com/manual/page_usrp2.html#usrp2_network
https://kb.ettus.com/USRP_N_Series_Quick_Start_(Daughterboard_Installation)#Step_9
https://kb.ettus.com/Building_and_Installing_the_USRP_Open-Source_Toolchain_(UHD_and_GNU_Radio)_on_Linux#Configuring_Ethernet
They all tell me to configure the ethernet adapter to use an IP address of 192.168.10.1 with a netmask of 255.255.255.0, so I did so using the GUI utilities:
Then I should be able to ping the N210 at its default IP of 192.168.10.2, but all I get is Destination Host Unreachable:
~$ ping 192.168.10.2
PING 192.168.10.2 (192.168.10.2) 56(84) bytes of data.
From 192.168.10.1 icmp_seq=1 Destination Host Unreachable
From 192.168.10.1 icmp_seq=2 Destination Host Unreachable
From 192.168.10.1 icmp_seq=3 Destination Host Unreachable
...
It has been many years since I had a computer networking course (and I am not a programmer or network admin by trade), so I feel sort of clueless. Does anyone here have some tips on how to proceed? If the N210, for some reason, is configured to use a non-default IP, how do I find its IP?
Details
The physical setup (schematically):
laptop - USB/ethernet adapter - ethernet cable - N210
The above sources emphasize that the connection must be Gigabit Ethernet. The cable has HYPER-DATA 1000 written on it, so it seems to be up to spec. Additionally, as can be seen below, the Ethernet interface seems to automatically configure itself with speed=1Gbit/s, so that also seems correct.
Some additional information (... means I have removed one or more lines):
~$ ifconfig
enx9cebe8351e07: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.10.1 netmask 255.255.255.0 broadcast 192.168.10.255
inet6 fe80::d645:c1a1:99ea:a022 prefixlen 64 scopeid 0x20<link>
ether 9c:eb:e8:35:1e:07 txqueuelen 1000 (Ethernet)
RX packets 6 bytes 384 (384.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 283 bytes 44546 (44.5 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
...
~$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default _gateway 0.0.0.0 UG 600 0 0 wlp2s0
...
link-local 0.0.0.0 255.255.0.0 U 1000 0 0 wlp2s0
192.168.10.0 0.0.0.0 255.255.255.0 U 100 0 0 enx9cebe8351e07
~$ sudo lshw -c network
...
*-network
description: Ethernet interface
physical id: 1
bus info: usb@1:3
logical name: enx9cebe8351e07
serial: 9c:eb:e8:35:1e:07
size: 1Gbit/s
capacity: 1Gbit/s
capabilities: ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=r8152 driverversion=v1.11.11 duplex=full firmware=rtl8153a-2 v1 10/23/19 ip=192.168.10.1 link=yes multicast=yes port=MII speed=1Gbit/s
|
If I interpret the ping output correctly, the ping packet reaches the N210, which replies with an ICMP packet (you can verify that with tcpdump), which means the N210 is very likely configured for a different address.
The manual says
Change the USRP2's IP address (Method 2)
This method assumes that you do not know the IP address of your USRP2. It uses raw Ethernet packets to bypass the IP/UDP layer to communicate with the USRP2. Run the following commands:
cd <install-path>/lib/uhd/utils
sudo ./usrp2_recovery.py --ifc=eth0 --new-ip=192.168.10.3
That seems to assume you somehow have the software received with the N210, or you can download it from somewhere, and you have installed it.
If you don't have the software, you can also try nmap, and scan for addresses. Start with the private IP address ranges.
| Ethernet config for computer-USRP communication |
1,513,075,304,000 |
Upon the install of BigBlueBotton in Debian 9, I run the script bbb-conf --check to make consistency checks of the setup. (bbb-conf is a configuration/setup tool to BBB)
The script return me in all consistency checks the address of the machine as inet. What is happening?
|
I have found out why bbb-conf is not seeing the IP address correctly.
bbb-conf is a bash script that runs the ifconfig command.
The cause is that the output/fields of the ifconfig output changed in Debian version 9.
Thus, the regexps in the script no longer give a match to the current address.
In Debian 8/Jessie:
inet addr:193.136.188.36 Bcast:193.136.188.255 Mask:255.255.255.0
In Debian 9/Stretch:
inet 10.23.20.19 netmask 255.255.255.0 broadcast 10.23.20.255
Is it recommend to change the script to ip addr show as ifconfig is being deprecated, and the output of ip does not change across versions.
So instead of:
ifconfig | grep -v '127.0.0.1' | grep -E "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | tail -1 | cut -d: -f2 | awk '{ print $1}'
change it to:
ip addr show | grep inet | tail -1 | awk ' { print $2 } '
After changing/correcting the offending lines, the script already shows the IP address correctly, however now it spews as warnings, that the IP addresses in the configuration files are incorrect. The post-installation scripts also inserts inet instead of the correct address due to unfortunate changes to the ifconfig output format in Debian.
| BBB: `bbb-conf --check` showing IP addresses as `inet` - ifconfig woes |
1,513,075,304,000 |
My issue looks similar to this one.
I configure my Broadcom BCM4311 802.11b/g device on FreeBSD 10.3-STABLE like this:
sudo kldload if_bwn
sudo kldload bwn_v4_ucode
sudo kldload bwn_v4_lp_ucode
#
# Now, interface `bwn0` is available
#
sudo ifconfig wlan0 create wlandev bwn0
sudo ifconfig wlan0 up # at this moment, laptop WiFi LED light turns on
sudo ifconfig wlan0 scan # I can see my wireless router SSID
sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf
sudo ifconfig wlan0 list sta
sudo dhclient wlan0
#
# Optionally, rather than dhclient run:
#
sudo ifconfig wlan0 inet 192.168.1.103 netmask 0xffffff00
ifconfig shows wireless network status as associated:
$ ifconfig
bge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=8009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,LINKSTATE>
ether 00:15:c5:ad:63:9c
inet 192.168.1.101 netmask 0xffffff00 broadcast 192.168.1.255
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
media: Ethernet autoselect (100baseTX <full-duplex>)
status: active
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
inet 127.0.0.1 netmask 0xff000000
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
bwn0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 2290
ether 00:18:f3:38:a0:36
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
media: IEEE 802.11 Wireless Ethernet autoselect mode 11g
status: associated
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 00:18:f3:38:a0:36
inet 192.168.1.103 netmask 0xffffff00 broadcast 192.168.1.255
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
media: IEEE 802.11 Wireless Ethernet OFDM/48Mbps mode 11g
status: associated
ssid Mine channel 11 (2462 MHz 11g) bssid e8:de:27:6b:3e:67
country US authmode WPA2/802.11i privacy ON deftxkey UNDEF
TKIP 2:128-bit txpower 30 bmiss 7 scanvalid 60 bgscan bgscanintvl 300
bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS wme roaming MANUAL
$
I disconnect laptop Ethernet cable to check the wireless connection to router by following methods:
Wireless router shows that my laptop is listed among "Current Connected Wireless Clients":
ID MAC
1 00:18:F3:38:A0:36
Wireless router has a diagnostic ping tool by which I can ping to my laptop, when I do that, timed out message is received:
IP Address/Domain Name: 192.168.1.103
Request timed out
From my laptop I ping to router:
$ ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1): 56 data bytes
ping: sendto: No route to host
ping: sendto: No route to host
ping: sendto: No route to host
ping: sendto: No route to host
ping: sendto: No route to host
^C
--- 192.168.1.1 ping statistics ---
5 packets transmitted, 0 packets received, 100.0% packet loss
$
arp -an output:
$ arp -an
? (192.168.1.103) at 00:18:f3:38:a0:36 on wlan0 permanent [ethernet]
? (192.168.1.1) at e8:de:27:6b:3e:67 on bge0 expires in 803 seconds [ethernet]
? (192.168.1.101) at 00:15:c5:ad:63:9c on bge0 permanent [ethernet]
$
netstat -r output:
$ netstat -r
Routing tables
Internet:
Destination Gateway Flags Netif Expire
default 192.168.1.1 UGS bge0
localhost link#2 UH lo0
192.168.1.0 link#4 U wlan0
192.168.1.101 link#1 UHS lo0
192.168.1.103 link#4 UHS lo0
Internet6:
Destination Gateway Flags Netif Expire
:: localhost UGRS lo0
localhost link#2 UH lo0
::ffff:0.0.0.0 localhost UGRS lo0
fe80:: localhost UGRS lo0
fe80::%lo0 link#2 U lo0
fe80::1%lo0 link#2 UHS lo0
ff01::%lo0 localhost U lo0
ff02:: localhost UGRS lo0
ff02::%lo0 localhost U lo0
$
dmesg output from creating wlan0 interface up to dhclient command:
wlan0: Ethernet address: 00:18:f3:38:a0:36
bwn0: firmware version (rev 410 patch 2160 date 0x751a time 0x7c0a)
wlan0: ieee80211_new_state_locked: pending INIT -> SCAN transition lost
bwn0: status of RF switch is changed to OFF
bwn0: please turn on the RF switch
bwn0: firmware version (rev 410 patch 2160 date 0x751a time 0x7c0a)
bwn0: status of RF switch is changed to OFF
bwn0: please turn on the RF switch
wlan0: link state changed to UP
bwn0: need multicast update callback
bwn0: need multicast update callback
bwn0: need multicast update callback
Configuration files
I don't use /etc/rc.conf, I do everything manually. I use following wpa_supplicant configuration:
$ cat /etc/wpa_supplicant.conf
network={
ssid="Mine"
psk=79a174594e2ec3563ff4c35c1a82a006b19df646fa020aaf53078d34d09ed962
}
$
I wonder if anybody can give a hand.
UPDATE:
Now, I'm using /etc/rc.conf like this:
#
# Kernel modules to load after local disks are mounted
#
kld_list="linux nvidia if_bwn bwn_v4_ucode bwn_v4_lp_ucode fuse"
#
# DELL LATITUDE | D820
#
hostname="D820"
#
# $ sudo ifconfig wlan0 create wlandev bwn0
#
wlans_bwn0="wlan0"
#
# $ sudo ifconfig wlan0 up
# $ sudo ifconfig wlan0 scan
# $ sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf
# $ sudo dhclient wlan0
#
wpa_supplicant_conf_file="/etc/wpa_supplicant.conf"
ifconfig_wlan0="WPA DHCP"
#
# gnome3-lite desktop environment services
#
#dbus_enable="YES"
#hald_enable="YES"
#gdm_enable="YES" # GDM will start automatically when the system boots
#gnome_enable="YES"
#linux_enable="YES"
##
## To enable the tor server
##
#tor_enable="YES"
##
## web proxy of choice
##
#polipo_enable="YES"
#privoxy_enable="YES"
##
##For Linux compatibility to be enabled at boot time
##
linux_enable="YES"
|
When you booted your laptop and configured the wired bge0 interface via dhclient, it became the default route (as seen in the rightmost column in the output of netstat -r). When you later configured your wireless bwn0 interface and disconnected the wired interface, it wasn't set to be the default route. When you tried to access the network (or reply to requests), traffic was trying to use bge0 but it was disconnected.
Rebooting your laptop you can just configure the wireless interface and not have this problem.
If you want to move from wired to wireless in the future, I believe you can do the following:
route change default -iface wlan0
route change default 192.168.1.1
This sets the default route interface to the wireless one, which resets the router address, so we re-add it in the second line.
| Configure wireless network on FreeBSD: router shows wireless device is connected, but cannot ping |
1,513,075,304,000 |
I just got a second IP address for my Debian Squeeze root. I tried to add the address to my network but somehow I messed up. The command I executed:
ifconfig eth0 [new ip address] mask 255.255.255.254
Now, I cant get any response from the server e.g. Apache, ftp etc.
I did not try to restart it yet.
Is there any possibility to fix this?
|
You didn't add the second IP address, but instead replaced the first IP address.
You should be able to access the server via that second IP address, if the netmask is correct and any firewall allows access to that IP address.
For reference, it's easiest IMHO to add extra IP addresses via:
ip addr add newip/32 dev eth0
Use /32 if the new address is within the same netmask as an existing IP address, otherwise use the real netmask (in your case /31 for 255.255.255.254).
Removal is done with e.g.:
ip addr del newip/32 dev eth0
If the extra Ip address is permanent, add a line to the iface eth0 inet static paragraph:
up ip addr add newip/32 dev eth0
| ifconfig made my server unreachable |
1,513,075,304,000 |
Set up/configuration:
I have a RHEL 8 server, running Asterisk 15.x, that has 2 NICs. NMCLI is used for networking
NIC0 (eno5np0) is on the trusted network and is configured as a static IPv4 and NIC1 (ens1f0) is on the untrusted side as a DHCP IPv4. Both are UP,BROADCAST,RUNNING,MULTICAST
NIC0 is where I access the server from, is an internal network and has an IP of 10.38.149.244/32 (GW is 10.38.149.241) NIC1 is supposed to allow access to the internet (for SIP calling) and has an IP of 10.0.0.91 (GW is 10.0.0.1)
Firewall status - inactive(dead)
SE Linux status - disabled
Server #1 interface configs:
TYPE=Ethernet
DEVICE=eno5np0
UUID=77c33e7a-7dba-4785-b749-dc0883b46cef
ONBOOT=yes
IPADDR=10.38.149.244
NETMASK=255.255.255.240
GATEWAY=10.38.149.241
NM_CONTROLLED=yes
BOOTPROTO=none
DOMAIN=comcast.net
DNS1=69.252.80.80
DNS2=69.252.81.81
DEFROUTE=yes
USERCTL=no
IPV4_FAILURE_FATAL=yes
TYPE=Ethernet
BOOTPROTO=dhcp
NM_CONTROLLED=yes
PEERDNS=no
DEFROUTE=no
NAME=ens1f0
UUID=249b95f0-d490-4402-b654-43695317d738
DEVICE=ens1f0
ONBOOT=yes
PROXY_METHOD=none
BROWSER_ONLY=no
IPV4_FAILURE_FATAL=no
IPV6_DISABLED=yes
IPV6INIT=no
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
Kernel IP routing table:
Destination
Gateway
Genmask
Flags
Metric
Ref
Use
Iface
0.0.0.0
10.38.149.241
0.0.0.0
UG
100
0
0
eno5np0
10.0.0.0
0.0.0.0
255.255.255.0
U
101
0
0
ens1f0
10.38.149.240
0.0.0.0
255.255.255.240
U
100
0
0
eno5np0
I do not have any nft tables/IP tables configured
I am SSH'd to the 10.38.149.244 interface (NIC0, aka eno5np0), have sudo access
I run the following command for NIC0: sudo traceroute -i eno5np0 8.8.8.8 and get a nice, completed trace to 8.8.8.8
I run the following command for NIC1: sudo traceroute -i ens1f0 8.8.8.8 and it times out, no packets received
I cannot ping/traceroute to any ip address through NIC1 (sudo ping -I and sudo traceroute -i) except 10.0.0.1, which is the gateway. It is almost like if it isn't the gateway the packets are not making it back into the server for processing?
Issue/Problem
So, after trying both ping and traceroute and not receiving a response, I opened a second SSH session to the server and did a tcpdump while running a ping to 8.8.8.8 over the NIC1 interface in my first SSH session:
TCP Dump
sudo tcpdump -vv --interface ens1f0 -c 10
dropped privs to tcpdump
tcpdump: listening on ens1f0, link-type EN10MB (Ethernet), capture size 262144 bytes
15:21:09.450739 IP6 (flowlabel 0x9b9b7, hlim 255, next-header ICMPv6 (58) payload length: 120) fe80::1256:11ff:fe86:6e92 > ff02::1: [icmp6 sum ok] ICMP6, router advertisement, length 120
hop limit 64, Flags [managed, other stateful], pref medium, router lifetime 180s, reachable time 0ms, retrans timer 0ms
rdnss option (25), length 40 (5): lifetime 180s, addr: device1.inetprovider.net addr: device2.inetprovider.net
0x0000: 0000 0000 00b4 2001 0558 feed 0000 0000
0x0010: 0000 0000 0001 2001 0558 feed 0000 0000
0x0020: 0000 0000 0002
prefix info option (3), length 32 (4): 2601:0:200:80::/64, Flags [onlink, auto], valid time 300s, pref. time 300s
0x0000: 40c0 0000 012c 0000 012c 0000 0000 2601
0x0010: 0000 0200 0080 0000 0000 0000 0000
route info option (24), length 24 (3): ::/0, pref=medium, lifetime=180s
0x0000: 0000 0000 00b4 0000 0000 0000 0000 0000
0x0010: 0000 0000 0000
source link-address option (1), length 8 (1): 10:56:11:86:6e:92
0x0000: 1056 1186 6e92
15:21:10.415419 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has dns.google tell 10.0.0.91, length 28
15:21:11.439570 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has dns.google tell 10.0.0.91, length 28
15:21:12.453262 IP6 (flowlabel 0x9b9b7, hlim 255, next-header ICMPv6 (58) payload length: 120) fe80::1256:11ff:fe86:6e92 > ff02::1: [icmp6 sum ok] ICMP6, router advertisement, length 120
hop limit 64, Flags [managed, other stateful], pref medium, router lifetime 180s, reachable time 0ms, retrans timer 0ms
rdnss option (25), length 40 (5): lifetime 180s, addr: device1.inetprovider.net addr: device2.inetprovider.net
0x0000: 0000 0000 00b4 2001 0558 feed 0000 0000
0x0010: 0000 0000 0001 2001 0558 feed 0000 0000
0x0020: 0000 0000 0002
prefix info option (3), length 32 (4): 2601:0:200:80::/64, Flags [onlink, auto], valid time 300s, pref. time 300s
0x0000: 40c0 0000 012c 0000 012c 0000 0000 2601
0x0010: 0000 0200 0080 0000 0000 0000 0000
route info option (24), length 24 (3): ::/0, pref=medium, lifetime=180s
0x0000: 0000 0000 00b4 0000 0000 0000 0000 0000
0x0010: 0000 0000 0000
source link-address option (1), length 8 (1): 10:56:11:86:6e:92
0x0000: 1056 1186 6e92
15:21:12.463417 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has dns.google tell 10.0.0.91, length 28
15:21:13.487416 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has dns.google tell 10.0.0.91, length 28
15:21:13.546246 IP (tos 0x0, ttl 4, id 8382, offset 0, flags [DF], proto UDP (17), length 219)
169.254.100.1.50760 > 239.255.255.250.ssdp: [udp sum ok] UDP, length 191
15:21:13.546273 IP (tos 0x0, ttl 4, id 8383, offset 0, flags [DF], proto UDP (17), length 223)
169.254.100.1.50760 > 239.255.255.250.ssdp: [udp sum ok] UDP, length 195
15:21:13.546320 IP (tos 0x0, ttl 4, id 8384, offset 0, flags [DF], proto UDP (17), length 227)
169.254.100.1.50760 > 239.255.255.250.ssdp: [udp sum ok] UDP, length 199
15:21:13.546419 IP (tos 0x0, ttl 4, id 8385, offset 0, flags [DF], proto UDP (17), length 220)
169.254.100.1.50759 > 239.255.255.250.ssdp: [udp sum ok] UDP, length 192
10 packets captured
10 packets received by filter
0 packets dropped by kernel
I am not understanding why, if the server is doing an ARP request, am I not getting a response? Is the issue on my server not knowing how to respond back to NIC0 with my ping request (where I am SSH'd into)? Is it the gateway being misconfigured? Do I need a NFT table/IP Table configured?
I am familiar with how to do this in RHEL 6.x, but not in RHEL 8 (configuration using IP route and IP tables was simpler I think?)
At the end of the day (for a broader picture) - I have Softphone clients to register to the Asterisk PBX on the internal/trusted network coming in over NIC0 (which works). They need to make phone calls to endpoints on the Internet, but only over NIC1 - and right now I cannot even ping to any location on the internet over the NIC1 interface.
Any help/guidance would be very much appreciated at this point - I am lost and desperate.
Edit/additional clarification:
I have a RHEL 6.x server, with exact same physical connections and NICs that this does work on. I have tried to use the iptable and routing table from this Server #2 on Server #1 above and it will not work (I get booted when I turn the interface back up, and have to reboot the device to clear out any unsaved changes before I can get back in) I did use the iptables to nft translate function just as an FYI. I have plugged my Server #1 NIC1 into the known good modem/internet access port that Server #2 is using and still no change.
Server #2 interface configs:
DEVICE=eth0
BOOTPROTO=none
NM_CONTROLLED=yes
ONBOOT=yes
TYPE=Ethernet
UUID="da71293d-4351-481e-a794-bc5850e29391"
IPADDR=10.38.149.243
DNS1=10.168.241.223
DOMAIN=comcast.net
DEFROUTE=no
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
#HWADDR=00:1C:23:CF:BC:E3
HWADDR=00:1c:23:cf:bc:e3
NETMASK=255.255.255.240
USERCTL=no
PEERDNS=yes
GATEWAY=10.38.149.241
DEVICE=eth1
BOOTPROTO=dhcp
HWADDR=00:1c:23:cf:bc:e5
NM_CONTROLLED=yes
ONBOOT=yes
DEFROUTE=yes
TYPE=Ethernet
UUID="78bc69cb-80ca-41d1-af9c-66703eb952d5"
USERCTL=no
PEERDNS=yes
IPV6INIT=no
Kernel Routing Table on Server #2
Destination
Gateway
Genmask
Flags
Metric
Ref
Use
Iface
0.0.0.0
10.0.0.1
255.255.255.255
UGH
0
0
0
eth1
10.38.149.240
0.0.0.0
255.255.255.240
U
0
0
0
eth0
10.0.0.0
0.0.0.0
255.255.255.0
U
0
0
0
eth1
10.0.0.0
10.38.149.241
255.0.0.0
UG
0
0
0
eth0
0.0.0.0
10.0.0.1
0.0.0.0
UG
0
0
0
eth1
iptables -L on Server #2
Chain INPUT (policy ACCEPT)
target
prot
opt
source
destination
status?
DROP
all
--
c-67-164-235-175.devivce1.mi.inetprovider.net
anywhere
DROP
all
--
c-67-164-235-175.devivce1.mi.inetprovider.net
anywhere
ACCEPT
all
--
anywhere
anywhere
ACCEPT
all
--
anywhere
anywhere
state RELATED,ESTABLISHED
ACCEPT
tcp
--
anywhere
anywhere
tcp dpt:ssh
ACCEPT
udp
--
anywhere
anywhere
udp dpt:sip
ACCEPT
udp
--
anywhere
anywhere
udp dpts:ndmp:dnp
DROP
all
--
106.0.0.0/8
anywhere
DROP
all
--
106.0.0.0/8
anywhere
DROP
all
--
host-87-0-0-0.retail.blockeddomain.notus/8
anywhere
DROP
all
--
113.0.0.0/8
anywhere
DROP
all
--
117.0.0.0/8
anywhere
DROP
all
--
p5b000000.dip0.blockeddomain.notus/8
anywhere
Chain FORWARD (policy ACCEPT)
target
prot
opt
source
destination
ACCEPT
all
--
anywhere
anywhere
Chain OUTPUT (policy ACCEPT)
target
prot
opt
source
destination
|
A gateway with a genmask of 0.0.0.0 is a "default gateway". In other words, it means "unless otherwise specified, the rest of the world is this way." In a simple multi-homed host configuration, there should be just one default gateway in the entire system at a time. You cannot really use two NATted internet connections in parallel, unless you at least have an exact control of how the NAT is done. The best you can probably do with two average consumer-grade Internet connections (with a provider-dictated NAT on each) is to use one as a primary, with an automatic fall-back to the second one if the first one loses a link.
You have a default gateway configured on eno5np0 interface, but not on the ens1f0 interface. There are no more specific routes either, just the auto-generated network entries for the local network segment of each interface. This is probably because your system's DHCP client detects you already have a statically-configured default gateway on eno5np0, so it won't mess things up by adding another.
As a result, the system has no clue that it should send outgoing traffic addressed to 8.8.8.8 via 10.0.0.1 if sending it out through ens1f0. By your routing table, only addresses in the form of 10.0.0.* should be reachable through that interface.
But because you are explicitly telling traceroute to try and reach 8.8.8.8 via ens1f0, it assumes you are trying to debug a possibly misconfigured server in your local network segment, and sends out direct ARP requests for that IP address.
You should never see an ARP request for 8.8.8.8 in your own network (unless you are next-door to a Google's datacenter and have somehow managed to get a neighborly direct-link to their network :-) unless something is misconfigured. Instead, you should see an ARP request for the default gateway in that segment, and then this system should send any outgoing traffic bound to 8.8.8.8 to the gateway.
Your system also probably has a IP Reverse Path Filtering in effect. Basically, since your routing table says that the ens1f0 interface has connectivity to the 10.0.0.* addresses only, any packets with source addresses not in that range coming in via that interface would get discarded as fakes. That would cause any responses from 8.8.8.8 coming in via 10.0.0.1 to be discarded as long as your current routing table is in effect.
| RHEL 8 IP/Kernel Routing Multi-Homed Server Issue - Cannot get a response to ping, when trying to ping from 2nd Interface |
1,423,471,335,000 |
ifconfig gives following output:
eth0 Link encap:Ethernet HWaddr 4c:87:0e:z3:e7:11
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:35767 errors:0 dropped:0 overruns:0 frame:0
TX packets:35767 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:5053027 (5.0 MB) TX bytes:5053027 (5.0 MB)
vmnet1 Link encap:Ethernet HWaddr 60:80:66:m0:00:01
inet addr:192.168.139.1 Bcast:192.168.139.255 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fec0:1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:70 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
I presently need output like
eth0
wlan0 127.0.0.1
vmnet1 192.168.139.1
so i run command
ifconfig | awk '/encap|inet addr/{ print }'
but i am stuck now, as i need to combine 2 lines based on weather the next line contains the ipaddress pattern. Though shell script may do the trick ,
But i need a simple single command solution.
Though for loops are there in awk , but forward looking into next line , matching & then printing on console is challenge for me .
or is there a simple command / flag for achieving such purpose ?
route command seems to do the trick (awk field extraction!!) , but it doesnot list the inactive interfaces.
|
finally found ifconfig based solution!
String s="ifconfig | awk -F '[ :]' '/encap|inet addr/{ if($1 != \"\" ){ print $1 \":\" $13 } else print $13 }'| awk -F \":\" '{print $1}'| awk '{ curr=$1 ; if(!system(\"echo \"$1\"|grep ^[0-9]>/dev/null\")) {print prev \"\\t : \" curr;prev=\"\"} else { if(prev!=\"\") {print prev \"\\t : not assigned\" }; prev=$1 } }'"
explanation :
root$ ifconfig | awk -F '[ :]' '/encap|inet addr/{ if($1 != "" ){ print $1 ":" $13 } else print $13 }'| awk -F ":" '{print $1}'
eth0
lo
127.0.0.1
vmnet1
192.168.139.1
vmnet8
192.168.152.1
wlan0
10.208.7.86
so , i have piped the above output to another awk command:
| awk '{ curr=$1 ; if(!system("echo "$1"|grep ^[0-9]>/dev/null")) {print prev "\t : " curr;prev=""} else { if(prev!="") {print prev "\t : not assigned" }; prev=$1 } }'
here , if i find two consecutive interface names, then i print the name of previous interface with custom messge "not assigned" .if i get numeric pattern in string then current string(ipaddress) along with the previous interface name is printed !
| Printing interface-ipaddress through single command (piped) |
1,423,471,335,000 |
When we test the eth card with ethtool -S
we get rx_missed_errors: 4649.
What is the meaning of rx_missed_errors?
Is it a major problem?
rx_over_errors: 0
rx_crc_errors: 0
rx_frame_errors: 0
rx_fifo_errors: 0
rx_missed_errors: 4649
tx_aborted_errors: 0
tx_carrier_errors: 0
tx_fifo_errors: 0
tx_heartbeat_errors: 0
rx_long_length_errors: 0
rx_short_length_errors: 0
rx_csum_offload_errors:
ethtool -g eth847
Ring parameters for eth847:
Pre-set maximums:
RX: 8192
RX Mini: 0
RX Jumbo: 0
TX: 8192
Current hardware settings:
RX: 1024
RX Mini: 0
RX Jumbo: 0
TX: 1024
|
The exact meaning of rx_missed_errors depends on the Ethernet driver in use, but it’s supposed to count missed packets on the receiver side, i.e. packets which the NIC received but had to drop because they couldn’t be stored or processed — typically, because the FIFO they would have gone to was full.
Whether it’s a major problem depends on the traffic being dropped. In most cases, dropped packets will end up retransmitted if necessary, by one layer of the stack or another.
If the drops are bursty, you could try increasing the buffers (if your NIC allows you to): check the maximum setting with ethtool -g, and set it with ethtool -G. In your case, you can set the receive and transmit rings to anything up to 8192:
ethtool -G eth847 rx 8192
It’s not necessarily a good idea to set the buffer to the maximum value immediately: larger buffers can result in increased latency. I suggest increasing the buffers progressively, and watching the error rate to see how it evolves.
| What is the meaning of rx_missed_errors? |
1,423,471,335,000 |
I have this output in the following and I am trying to convert it to JSON api format. I want to know how can I do it.
rock64@rockpro64:~$ sh MACscript.sh
eth0
11:1d:11:11:11:1d
lo
00:00:00:00:00:00
Do I have to use python script or can I do it using shell script?
This is my MACshell script:
rock64@rockpro64:~$ cat MACscript.sh
!/bin/bash
getmacifup.sh: Print active NICs MAC addresses
D='/sys/class/net'
for nic in $( ls $D )
do
echo $nic
if grep -q unknown $D/$nic/operstate
then
echo -n ' '
cat $D/$nic/address
fi
done
|
With plain bash you could do:
json=$(
sh MACscript.sh | {
pairs=()
while read interface; read ether; do
pairs+=("\"$interface\":\"$ether\"")
done
IFS=,
echo "{${pairs[*]}}"
}
)
echo "$json"
outputs
{"eth0":"11:1d:11:11:11:1d","lo":"00:00:00:00:00:00"}
| How to convert shell output to JSON? |
1,423,471,335,000 |
I am using the follwing to find the mtu value
ifconfig | grep mtu
eno17832: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 9000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
but in my bash script we want to know exactly the MTU value
so we can use this
MTU_VAL=` ifconfig | grep mtu | head -1 | awk '{print $NF}' `
but this may be risky and no so elegant
please let me know if we can capture the MTU for sure ?
|
Most tools leverage information present in /proc or /sys, concerning ifconfig I'd go with /sys/class/net/<interface>/* files:
To get mtu for all interfaces but loopback (lo) this would work:
cat /sys/class/net/[^l][^o]*/mtu
The exclusion is done by shell globing, anything not starting with l then o is expanded and then the mtu file within it is read. If there's only one interface other than loopback it will return its mtu as a single value, usable in script with $() to put the output in a variable.
To answer the comment:
$ awk '{split(FILENAME,arr,"/"); print arr[5],$1}' /sys/class/net/*/mtu
ens160 1500
lo 65536
Same pattern match as above to exclude lo if needed (I've kept it here to showcase multiple interface output).
| what is the best approach to capture the MTU value |
1,423,471,335,000 |
Looking at the output of ifconfig or ip link show. Can an interface status be UP/RUNNING/active without an IP address assigned to it?
|
Yes, it can be UP and RUNNING without an IP address. This can even be useful, e.g. if you are just interested in sending/receiving layer 2 frames, or if you are running a different layer 3 protocol than IP.
| Can an interface status be active without an IP address assigned to it? |
1,423,471,335,000 |
I need the user be able to change the IP address, without giving him full super user access. How can I do that?
I tried the solution here https://serverfault.com/a/480823
That works fine, but only once, then I have to redo these steps again.
How can I grant the user permission to change the IP address whenever he feels like to?
Edit: I did not rm the file, as outlined in the link above. But when I try it again, I get errors like
SIOCSIFADDR: Permission denied
SIOCSIFFLAGS: Permission denied
SIOCSIFNETMASK: Permission denied
SIOCSIFBROADCAST: Permission denied
just as if I used ifconfig directly.
|
Easy way to change ip address is on the command line with ifconfig
# ifconfig <interface> <ipaddress> netmask <netmask>
sudo /sbin/ifconfig 192.168.0.1 netmask 255.255.255.0
# for changing gateway if desired
sudo /sbin/route add default gw 192.168.0.253 eth0
you edit the sudoers file using visudo
Option 1: create a new group, called ipchangers for example. Then in visudo append at the bottom of file
%ipchangers ALL = NOPASSWD: /sbin/ifconfig
%ipchangers ALL = NOPASSWD: /sbin/route {if desired}
be sure to instruct your ipchangers users that they have to type sudo /sbin/ifconfig. And you add all users to the ipchangers group you wish to have ability to run ifconfig
Option 2: do it for just a specific user(s) joe and jack for example, you do it without the %
john ALL=NOPASSWD: /sbin/ifconfig
jack ALL=NOPASSWD: /sbin/ifconfig
when exiting visudo it should cleanly exit. If not and it gives something like
>>> /etc/sudoers: syntax error near line 57 <<<
What now?
then your syntax is wrong. follow the subsequent instructions and correct the syntax, don't save a bad sudoers file.
Be aware whoever you grant ability to run ifconfig is allowed to use ifconfig o its fullest extent and can do more than just change ip address with it.
| How can I grant permission to a user to change the IP address? |
1,423,471,335,000 |
I am trying to modify the ethernet device name without modifying grub. I have tried to modify the device name, but when I do, the device stops working.
Things I have tried:
I've tried this
nmcli con edit id "Wired connection 1"
set connection.id testname
save
quit
I've also tried this:
nmcli connection modify ens33 connection.id testname
But neither of those change the device name, which is what I need (so I can access the device with ifconfig or ip addr)
I've also tried this
ifdown ens33
ifconfig ens33 down
ip link set ens33 name testname
mv /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-testname
vi /etc/sysconfig/network-scripts/ifcfg-testname
ifconfig testname up
ifup testname
which appears to work at first glance because i can access the device with ifconfig, but after I bring the interface back up it fails to ping the target device (although it can ping itself).
The answer on this page looks promising, but I can't access it: https://access.redhat.com/solutions/108823
I must be missing a step, does anybody have an idea?
|
Changing the name of my network interface caused my mac address to change, therefore it would fail at the mac layer. By hardcoding the mac address into the /etc/sysconfig/network-scripts/ifcfg-testname file using the HWADDR directive, then the interface name change would work just fine; (It failed when I used the MACADDR directive).
This failed:
vim /etc/sysconfig/network-scripts/ifcfg-testname
MACADDR=xx:xx:xx:xx:xx
This succeeded:
vim /etc/sysconfig/network-scripts/ifcfg-testname
HWADDR=xx:xx:xx:xx:xx
found helpful info here:
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_networking/consistent-network-interface-device-naming_configuring-and-managing-networking#how-the-network-device-naming-works_consistent-network-interface-device-naming
| RHEL 8 - How can I modify an ethernet device name? |
1,423,471,335,000 |
I am using KVM to host a Guest VM. On my host VM, I have created 2 bridges and assigned each to a physical interface (assigned a subnet to them as well).
The routing all works very well, I can ping external resources to and from the interfaces.
I then assigned these 2 bridges to the guest VM, which is running FreeBSD. When I log in to the FreeBSD Guest and view network config, I see these 2 curr medias:
root@VM% ifconfig -a | grep "curr media"
curr media: i802 52:53:f:6f:e2:b2
curr media: i802 52:53:f:3b:24:22
When I check out all the interfaces on my Host Ubuntu VM, I see the following:
vnet1 Link encap:Ethernet HWaddr fe:53:0f:6f:e2:b2
vnet2 Link encap:Ethernet HWaddr fe:53:0f:3b:24:22
This is extremely confusing, as I would assume the interface in FreeBSD would have the same mac address as the associated VNET.
Does FreeBSD change the mac addresses from fe to 52? Or does the freeBSD interface take on a different mac address than the associated VNET?
More related confusions:
1) If 2 bridges, with routing, are assigned to a guest VM, is there a VNET created for each bridge on the host?
2) If 2 bridges are created, one assigned to 1 VM, and another assigned to another VM. Would there still be 2 VNETS?
3) If 2 bridges, are created on a host VM. However, one bridge is assigned to 1 VM and another bridge is assigned to 2 VMs, would there be 3 VNETS created on the host VM?
The reason for this clarification is because I see a whole bunch of VNETs.. and I have not idea where they come from (as I cannot seem to make sense of the MAC addresses) and I cannot seem to take them off because they arent in the network/interfaces file of ubuntu.
|
When using KVM, the interface MAC address on the host side is never the same as the MAC address inside the VM, regardless of the OS. It's a consequence of TUN/TAP networking.
For example, with a CentOS 7 VM running:
$ ip link show v-test1
64: v-test1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 500
link/ether fe:54:00:0c:d8:88 brd ff:ff:ff:ff:ff:ff
$ ssh test1 /sbin/ip link show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
link/ether 52:54:00:0c:d8:88 brd ff:ff:ff:ff:ff:ff
We can see similar with a Solaris 11 VM:
55: v-solaris: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 500
link/ether fe:54:00:94:47:6d brd ff:ff:ff:ff:ff:ff
$ ssh solaris ifconfig -a
....
net0: flags=100001004843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,IPv4,PHYSRUNNING> mtu 1500 index 2
inet 10.0.0.157 netmask ffffff00 broadcast 10.0.0.255
ether 52:54:0:94:47:6d
So it doesn't matter what the VM OS is; the MAC address seen inside the VM will always be different to that seen on the host side.
Now you can normally pick the interface name on the host side and the MAC address on the guest side via the configuration. I use libvirt to manage my VMs and so in my guest.xml file I have
<interface type='bridge'>
<mac address='52:54:00:0c:d8:88'/>
<source bridge='br0'/>
<target dev='v-test1'/>
<model type='virtio'/>
</interface>
This creates a network called "v-test1" on the host and the MAC address inside the guest is specified. This matches the first example above.
If you specify two network adapters for a host then you can pick what bridge on the host they are on, the network interface name as seen on the host, and the MAC addresses indepedently.
eg
<interface type='bridge'>
<mac address='52:54:00:0c:44:5d'/>
<source bridge='br0'/>
<target dev='v-test2'/>
<model type='virtio'/>
</interface>
<interface type='bridge'>
<mac address='52:54:00:0c:44:5e'/>
<source bridge='internal'/>
<target dev='v-test2b'/>
<model type='virtio'/>
</interface>
So now I've defined two interfaces, called one v-test2 and put it on bridge "br0" and another called v-test2b and put it on bridge "internal"
$ ip addr show v-test2
68: v-test2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 500
link/ether fe:54:00:0c:44:5d brd ff:ff:ff:ff:ff:ff
inet6 fe80::fc54:ff:fe0c:445d/64 scope link
valid_lft forever preferred_lft forever
$ ip addr show v-test2b
69: v-test2b: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 500
link/ether fe:54:00:0c:44:5e brd ff:ff:ff:ff:ff:ff
inet6 fe80::fc54:ff:fe0c:445e/64 scope link
valid_lft forever preferred_lft forever
$ brctl show
bridge name bridge id STP enabled interfaces
br0 8000.0025222613c0 no eth0
....
v-test2
internal 8000.fe54000c445e no v-test2b
And inside the guest we see them:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
link/ether 52:54:00:0c:44:5d brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
link/ether 52:54:00:0c:44:5e brd ff:ff:ff:ff:ff:ff
This makes it possible to define exactly what interfaces and MAC addresses and bridges each VM has.
| Does FreeBSD Change mac addresses of interfaces? |
1,423,471,335,000 |
I have a freebsd which has the network interfaces as follows.
bxe0, bxe1, igd0 and igd1
I want to move them to names like eth0, eth1 and so on. I know that I can do it in the /etc/rc.conf
ifconfig_igb0_name=eth0
but during the boot time the network interfaces are still bxe0, bxe1 etc.
Is there any way I can change interface names I want before the kernel gets loaded ?
Thanks in advance
|
Interfaces are "kernel inventions"; they don't exist outside of the kernel.
So "can I give them different names before the kernel gets loaded" makes no sense – they don't exist before the kernel has initialized them.
| bxe0 and bxe1 to eth0 and eth1 respectively |
1,423,471,335,000 |
I have build my LFS linux that based in this book, it's working fine and network interface card is working. Even it's configuring IP automatically with using dhcpcd service.
According chapter 9 in that books, there's file called
/etc/sysconfig/ifconfig.eth0
The problem is, what if I'm using wlan0, do I need to modify config file or rename eth0 to wlan0 every change network interface card MANUALLY, I expect it's detected automatically
Here init network script that generated by LFS book in /etc/init.d/network that related with /etc/sysconfig/ifconfig.*
### BEGIN INIT INFO
# Provides: $network
# Required-Start: $local_fs localnet swap
# Should-Start: $syslog firewalld iptables nftables
# Required-Stop: $local_fs localnet swap
# Should-Stop: $syslog firewalld iptables nftables
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: Starts and configures network interfaces.
# Description: Starts and configures network interfaces.
# X-LFS-Provided-By: LFS
### END INIT INFO
case "${1}" in
start)
# Start all network interfaces
for file in /etc/sysconfig/ifconfig.*
do
interface=${file##*/ifconfig.}
# Skip if $file is * (because nothing was found)
if [ "${interface}" = "*" ]; then continue; fi
/sbin/ifup ${interface}
done
;;
stop)
# Unmount any network mounted file systems
umount --all --force --types nfs,cifs,nfs4
# Reverse list
net_files=""
for file in /etc/sysconfig/ifconfig.*
do
net_files="${file} ${net_files}"
done
# Stop all network interfaces
for file in ${net_files}
do
interface=${file##*/ifconfig.}
# Skip if $file is * (because nothing was found)
if [ "${interface}" = "*" ]; then continue; fi
# See if interface exists
if [ ! -e /sys/class/net/$interface ]; then continue; fi
# Is interface UP?
ip link show $interface 2>/dev/null | grep -q "state UP"
if [ $? -ne 0 ]; then continue; fi
/sbin/ifdown ${interface}
done
;;
restart)
${0} stop
sleep 1
${0} start
;;
*)
echo "Usage: ${0} {start|stop|restart}"
exit 1
;;
esac
exit 0
# End network
|
By reading the script, it is obvious that it will process all /etc/sysconfig/ifconfig.* files:
start)
# Start all network interfaces
for file in /etc/sysconfig/ifconfig.*
do
interface=${file##*/ifconfig.}
The script will pick the name of the interface to configure from the filename, so you should simply write the settings you want for eth0 to /etc/sysconfig/ifconfig.eth0, and the settings you want for wlan0 to /etc/sysconfig/ifconfig.wlan0 respectively.
Also, note that for wireless network interfaces (like wlan0), you'll most likely also need to install and configure the wpa_supplicant, to handle the modern forms of wireless network security.
Being able to read shell scripts written by other people is a valuable skill for a Linux system administrator. Sometimes you may need to read a script to verify that it actually does what it claims to do; sometimes you may need to figure out what a script actually does in order to troubleshoot some problem, or because the available documentation is insufficiently detailed.
| Auto detect network interface card, network init.d |
1,423,471,335,000 |
Since some days ago , a strange interface showed up in my system and is there even when I close Virtualbox :
$ ifconfig
...
vboxnet0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 0a:00:27:00:00:00 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
vboxnet0:avahi: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 169.254.1.79 netmask 255.255.0.0 broadcast 169.254.255.255
ether 0a:00:27:00:00:00 txqueuelen 1000 (Ethernet)
...
After some time(maybe a minute) it goes default and causes my entire applications to use that instead of the Wi-Fi interface which is wlp9s0 :
$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 169.254.1.79 icmp_seq=1 Destination Host Unreachable
Note the IP address 169.254.1.79.
But if I run ifconfig vboxnet0 down:
$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=110 time=95.2 ms
But it last for perhaps a minute.
I haven't configured anything about that interface manually and there's no special configuration in my /etc/netplan/ directory.
And even I cannot delete it:
$ sudo ip link delete vboxnet0
RTNETLINK answers: Operation not supported
And here's the output of ip r in the event of that problem:
default dev vboxnet0 scope link metric 1004 linkdown
default via 192.168.1.1 dev wlp9s0 proto dhcp metric 20600
169.254.0.0/16 dev vboxnet0 proto kernel scope link src 169.254.1.79 linkdown
192.168.1.0/24 dev wlp9s0 proto kernel scope link src 192.168.1.104 metric 600
I've been using virtualbox networking for guest OSes for a long time but never encountered such a problem.
By the way I can run something like this:
while [ 1 ] ; do sudo ifconfig vboxnet0 down; sleep 20; done
to make sure it won't break anything , but what can I do about that?
BTW I'm using KDE Neon 5.18(= ubuntu 18.04).
Thanks in advance
|
As a workabout, since you don't use host-only networking, I suggest you delete vboxnet0 from VBox network settings. That way it will not be available and your problem will be solved.
You can delete it via File->Host Network Manager->Remove.
| vboxnet0 interface prevents applications to use Wi-Fi |
1,423,471,335,000 |
How can I get the in/out bytes separate for ifconfig??
I check packets and bytes by ifconfig .
ens3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 153.126.***.** netmask 255.255.254.0 broadcast 153.126.179.255
ether 9c:a3:ba:01:df:c3 txqueuelen 1000 (Ethernet)
RX packets 60777328 bytes 18377900528 (18.3 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 33420428 bytes 11013732175 (11.0 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
I run this script every day and gets byte.
However in this way, in/out packets are mixed.
Is there a way to separate in/out packets??
Or is it impossible for ifconfig (I need to use another tools???)
What I want to do is just get the in/out bytes/packets per day.
PATH="/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin"
NIC="ens3"
LOG="/var/log/transmit_bytes.log"
AT=`date '+%Y-%m-%d %H:%M:%S'`
TX=`cat /proc/net/dev | grep $NIC | sed -e 's/:/ /' | awk '{print$10}'`
echo "${AT} ${TX}" >> $LOG
exit 0
|
You can use netstat -ni to get the packets in an easily-parsable table.
For example, netstat -ni
Kernel Interface table
Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0 1500 1534430 0 0 0 605131 0 0 0 BMRU
lo 65536 20701 0 0 0 20701 0 0 0 LRU
tun0 1500 131763 0 0 0 177857 0 0 0 MOPRU
wlan0 1500 0 0 0 0 0 0 0 0 BMU
To pick out the received and transmitted packet count, something like this would be sufficient
netstat -ni | awk -v interface="eth0" '$1 == interface { print $3, $7 }'
Result
1534430 605131
For more modern systems with ip but without netstat, ip -s -j link show dev eth0 will provide a JSON formatted equivalent
[{"ifindex":2,"ifname":"eth0","flags":["BROADCAST","MULTICAST","UP","LOWER_UP"],"mtu":1500,"qdisc":"pfifo_fast","operstate":"UP","linkmode":"DEFAULT","group":"default","txqlen":1000,"link_type":"ether","address":"b8:27:eb:31:53:64","broadcast":"ff:ff:ff:ff:ff:ff","stats64":{"rx":{"bytes":182767514,"packets":1538635,"errors":0,"dropped":0,"over_errors":0,"multicast":0},"tx":{"bytes":268406197,"packets":606995,"errors":0,"dropped":0,"carrier_errors":0,"collisions":0}}}]
This can be parsed with something like jq
ip -s -j link show dev eth0 | jq '.[].stats64 | ( .rx.packets, .tx.packets )' | xargs
Output
1538635 606995
| How to get the in/out packets by ifconfig |
1,423,471,335,000 |
I have this output:
eth-g0 Link encap:Ethernet HWaddr 44
inet addr:222.222.22.22 Bcafdst:0.0.0.0
UP BROADCAST RUNNING MULTICAST MTU:1500
RX packets:9073618 errors:0 dropped:0 overruns:0
TX packets:6846448 errors:0 dropped:0 overruns:0
collisions:0 txqueuelen:1000
RX bytes:16fd45599237 (1.99 GiB) TX bytes:1937392674 (1.8
Interrupt:36
eth-g1 Link encap:Ethernet HWaddr 44
inet addr:22.222.222.22 Bcast:0.2.2.2
UP BROADCAST MULTICAST MTU:1500
RX packets:0 errors:0 dropped:0 overruns:0
TX packets:0 errors:0 dropped:0 overruns:0
collisions:0 txqueuelen:1200
RX bytes:0 (0.0 b) TX bytes:0 (0.0
Interrupt:37
I need this output:
eth-g0 inet 222.222.22.22
without the second line of the eth-g1 inet
(ofcourse it is a fiktive ip)
I'm trying to output this in one line without \n
I have tried so far
ifconfig| egrep -o "eth-g0...|inet................"
but it is not so good because some times there is
inet 222.22.22.222
and sometimes
inet addr 22.222.22.22
and it prints me with new lines everything.
|
Your question is a little difficult to decipher, but I think this might be what you are trying to do:
ifconfig | grep -A1 "^eth-g0 " | grep -Eo "^eth[^ ]+|inet (addr )?[^ ]+" | paste - -
I've based this solution on the commands you are trying to run, in the hope that it's easier to understand.
It's probably not the optimal way to do this.
| Extract interface name and IP address from "ifconfig" output |
1,423,471,335,000 |
on my RedHat 7, i noticed that network connection for Netbackup stopped working and i tried everything including rurning off my firewall and disabled SELINUX with no luck. the only thing i noticed different between this server and other servers is that port 1556 is listening on tcp & tcp6 where the same port on other servers only listen on tcp and not tcp6. Could that be causing the connection to stop? Is there a way to force port 1556 to listen ONLY on tcp and not tcp6?
here's what i see when i run netstat on port 1556
[root@server ~]# netstat -tupln | grep 1556
tcp 0 0 0.0.0.0:1556 0.0.0.0:* LISTEN 2498/pbx_exchange
tcp6 0 0 :::1556 :::* LISTEN 2498/pbx_exchange
|
It's hard to say exactly what's causing the error.
Having IPv6 enabled, and listening on the same port shouldn't cause issues.
Any system which has dual-stack capability should handle it fine.
I've found this bug report from Veritas (and I'm making an assumption that you're using what
they refer to as Netbackup) but I have no idea if this could be the issue you're facing. I will admit upfront that I do not have experience with Netbackup.
So I can only really answer the "is this what's causing the issue" part of the question.
As for the "can you force it to listen only on IPv4", you probably can, and it should be somewhere in the configuration for Netbackup pertaining to what port/IP addresses it's listening on. If it is listening on ALL available IP addresses for the server, and the server has dual-stack IPv4 and IPv6, it will listen for connections from both. So if you can bind Netbackup to an IPv4 address allocated to your server, that should disable the IPv6 functionality.
| port 1556 listening on tcp6 causing issues |
1,423,471,335,000 |
I've been using Debian GNU/Linux unstable (sid) for five months now without problems. A few days ago my computer wouldn't connect through ens33 (the Ethernet port at the back of my desktop, embedded in), and I had to use an external USB-to-Ethernet converter for internet. When I checked ifconfig -a, I was shocked there wasn't even an entry for ens33 and eth0 refuses to be run ifup or ifdown with.
ifconfig -a result:
enp2s0: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether 2c:27:d7:43:3f:03 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enx00e04c6803a1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.8.120 netmask 255.255.255.0 broadcast 192.168.8.255
inet6 fe80::2e0:4cff:fe68:3a1 prefixlen 64 scopeid 0x20<link>
ether 00:e0:4c:68:03:a1 txqueuelen 1000 (Ethernet)
RX packets 19402 bytes 22089157 (21.0 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 13011 bytes 1363539 (1.3 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 230 bytes 128048 (125.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 230 bytes 128048 (125.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
How can I add the standard Ethernet interface back?
ErikF's request:
lspci shows
00:00.0 Host bridge: Intel Corporation 4 Series Chipset DRAM Controller (rev 03)
00:02.0 VGA compatible controller: Intel Corporation 4 Series Chipset Integrated Graphics Controller (rev 03)
00:1b.0 Audio device: Intel Corporation NM10/ICH7 Family High Definition Audio Controller (rev 01)
00:1c.0 PCI bridge: Intel Corporation NM10/ICH7 Family PCI Express Port 1 (rev 01)
00:1c.1 PCI bridge: Intel Corporation NM10/ICH7 Family PCI Express Port 2 (rev 01)
00:1d.0 USB controller: Intel Corporation NM10/ICH7 Family USB UHCI Controller #1 (rev 01)
00:1d.1 USB controller: Intel Corporation NM10/ICH7 Family USB UHCI Controller #2 (rev 01)
00:1d.2 USB controller: Intel Corporation NM10/ICH7 Family USB UHCI Controller #3 (rev 01)
00:1d.3 USB controller: Intel Corporation NM10/ICH7 Family USB UHCI Controller #4 (rev 01)
00:1d.7 USB controller: Intel Corporation NM10/ICH7 Family USB2 EHCI Controller (rev 01)
00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev e1)
00:1f.0 ISA bridge: Intel Corporation 82801GB/GR (ICH7 Family) LPC Interface Bridge (rev 01)
00:1f.1 IDE interface: Intel Corporation 82801G (ICH7 Family) IDE Controller (rev 01)
00:1f.2 IDE interface: Intel Corporation NM10/ICH7 Family SATA Controller [IDE mode] (rev 01)
00:1f.3 SMBus: Intel Corporation NM10/ICH7 Family SMBus Controller (rev 01)
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8101/2/6E PCI Express Fast/Gigabit Ethernet controller (rev 02)
|
Debian is transitioning to Predictable Network Interface Names.
enp2s0 = Ethernet controller, bus 2, slot 0, first and only function, or in other words, PCI device 02:00.0. And the lspci output indicates it's a Realtek RTL8101/2/6E.
It looks like the RTL8106E at least needs a firmware file or two: you may need to have the firmware-realtek package installed from the non-free part of Debian. (Still available without paying anything, but with some extra copyright and/or licensing strings attached.)
https://packages.debian.org/unstable/kernel/firmware-realtek
ens33 would mean a PCIe hot-plug slot #33 based on information stored within system firmware; did you by any chance disable a PCIe hot-plug support module, thinking it unnecessary, at the time the problem appeared? Or did you do any kernel updates or configuration changes at that time?
A full decoding key for new-style NIC names is here.
| Debian Standard network interface doesn't work, have to use USB enx00e04c6803a1 [closed] |
1,423,471,335,000 |
I'm working on an embedded device that I think has a bad wifi antenna.
When I start the device I run ifconfig and see the wifi interface:
...
wlan3 Link encap:Ethernet HWaddr 08:ea:40:d7:63:27
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
I then make a wifi access point on my laptop with no password. I try to set the device to use it with iwconfig wlan3 essid philip.
Then I assign the interface an IP with dhclient wlan3 -v, the logs from verbose seem to indicate it was a success. Also I run ifconfig again and can see my interface has an IP:
...
wlan3 Link encap:Ethernet HWaddr 08:ea:40:d7:63:27
inet addr:192.168.12.120 Bcast:192.168.12.255 Mask:255.255.255.0
inet6 addr: fe80::aea:40ff:fed7:6327/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11 errors:0 dropped:34 overruns:0 frame:0
TX packets:30 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1846 (1.8 KB) TX bytes:7274 (7.2 KB)
Though I know in practicality I'm not connected because running ping -I wlan3 -c 1 8.8.8.8 fails.
Does the assignment of an IP confirm that my wifi did connect to the network? (with an incorrect password or ssid dhclient wlan3 seems to just hang)
Can I infer anything about a potential hardware problem from the RX and TX values in the second ifconfig?
End goal is to have my software tell the difference between an incorrect ssid/password and faulty hardware.
|
1) Yes.
2) No.
iw wlan3 station dump may give you better information to detect potential hardware problems, i.e. a missing or bad antenna.
3) If the problem is to detect an incorrect SSID or Password, and assuming you are (indirectly) using wpa_supplicant (and not WEP or no encryption), have a look at wpa_cli.
| Detecting bad antenna vs bad ssid/password with dhclient/ifconfig |
1,423,471,335,000 |
I am using rpi v3 so I have wlan as well. With this network config, when I am connected to wlan, I have internet access:
auto lo
iface lo inet loopback
iface eth0 inet manual
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
With this one I dont (even though still connected to same wlan):
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 10.10.10.1
netmask 255.255.255.0
gateway 10.10.10.5
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
What does eth0 have to do with anything here? Why does its configuration affect my lack of connection on wlan? I would appreciate all help really!
|
Remove the gateway entry under eth0. This adds a default route via 10.10.10.5, which is not what you want if internet traffic is supposed to go through wlan0.
| No internet on wlan then eth0 set to static |
1,423,471,335,000 |
Let us start from closing my eth0.192.168.1.4 is binded with eth0.
root@hwy:/home/debian8# ifconfig eth0 down
root@hwy:/home/debian8# route -nv
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 wlan0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
root@hwy:/home/debian8# ifconfig
eth0 Link encap:Ethernet HWaddr e0:3f:49:57:4b:d1
inet addr:192.168.1.4 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::e23f:49ff:fe57:4bd1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:918 errors:0 dropped:0 overruns:0 frame:0
TX packets:184 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:195407 (190.8 KiB) TX bytes:29304 (28.6 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:496 errors:0 dropped:0 overruns:0 frame:0
TX packets:496 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:728348 (711.2 KiB) TX bytes:728348 (711.2 KiB)
wlan0 Link encap:Ethernet HWaddr 00:21:5d:26:c1:10
inet addr:192.168.1.101 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::221:5dff:fe26:c110/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6556 errors:0 dropped:0 overruns:0 frame:0
TX packets:5709 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3528018 (3.3 MiB) TX bytes:999397 (975.9 KiB)
Maybe the eth0 is closed .
traceroute -i eth0 stackoverflow.com
traceroute to stackoverflow.com (104.16.36.249), 30 hops max, 60 byte packets
1 * * *
2 * * *
3 * * *
4 * * *
5 * * *
6 * * *
7 * * *
8 * * *
9 * * *
10 * * *
11 * * *
12 * * *
13 * * *
14 * * *
15 * * *
16 * * *
17 * * *
18 * * *
19 * * *
20 * * *
21 * * *
22 * * *
23 * * *
24 * * *
25 * * *
26 * * *
27 * * *
28 * * *
29 * * *
30 * * *
Something confued me that 192.168.1.4 can still be used in my local network.
There is a wordpress build on my local network.
root@hwy:/home/debian8# cat /etc/hosts
192.168.1.4 mywp.com
And all my url in the wordpress is in the form of http://mywp.com/wp/?p=2026.
If eth0 is closed by the command ifconfig eth0 down,the ip 192.168.1.4
can't be used,but why my wordpress can be visited on my local network?
There is only one result that the eth0 still work ,why can not be closed by the command
ifconfig eth0 down ?
Think to Warren Young .
ifdown eth0
ifdown: interface eth0 not configured
root@hwy:/home/debian8# ping 192.168.1.4
PING 192.168.1.4 (192.168.1.4) 56(84) bytes of data.
From 192.168.1.101 icmp_seq=1 Destination Host Unreachable
From 192.168.1.101 icmp_seq=2 Destination Host Unreachable
From 192.168.1.101 icmp_seq=3 Destination Host Unreachable
From 192.168.1.101 icmp_seq=4 Destination Host Unreachable
From 192.168.1.101 icmp_seq=5 Destination Host Unreachable
From 192.168.1.101 icmp_seq=6 Destination Host Unreachable
64 bytes from 192.168.1.4: icmp_seq=7 ttl=64 time=1001 ms
64 bytes from 192.168.1.4: icmp_seq=8 ttl=64 time=0.006 ms
64 bytes from 192.168.1.4: icmp_seq=9 ttl=64 time=0.026 ms
64 bytes from 192.168.1.4: icmp_seq=10 ttl=64 time=0.032 ms
Maybe this is a important clue:
My wordpress was build on local pc,there are two ips and two net cards on my local pc,192.168.1.4 was binded with eth0 ,192.168.1.101 was binded with wlan0.eth0 was banned by command ifdown eth0.
|
ifconfig eth0 down
Unless you're doing something uncommon (e.g. applying IP aliases) you should not be using ifconfig (or its successor, ip(8)) directly. You should say ifdown eth0 here. That takes care of many things that ifconfig does not.
traceroute -i eth0 stackoverflow.com
Your route table says the default route is via wlan0, not eth0, so you're not testing what you think you are.
192.168.1.4 can still be used in my local network
Of course. If you look back at the ifconfig output, you will see UP in the eth0 section.
192.168.1.4 mywp.com
You should not be using .com or other official TLDs for private networks. For purely local hosts defined in /etc/hosts, you don't need to fully-qualify them at all. This is perfectly legal:
192.168.1.4 mywp
With that /etc/hosts entry, you can visit http://mywp in your browser. Be careful: this movement in modern browsers to unify the search and location boxes means that typing mywp alone in the box will likely be treated as a web search term, not a host name. Most browsers will skip that if you include some sort of punctuation, so that mywp/ will tell the browser you mean for it to treat mywp as a host name, not a web search term.
If you feel the need for fully-qualified domain names, adjust your networking configuration to assign a local domain name to the LAN, such as literature.private. The .private TLD is a traditional option for local-only domains. (Another common alternative is .local.) The literature part I just took from your user name.
Having done that, the same /etc/hosts entry will still be looked up correctly if you go to http://mywp.literature.private in your web browser.
| Why can't close my eth0 by command `ifconfig eth0 down`? |
1,423,471,335,000 |
I earlier asked a question Wifi isnt working after using wifite [duplicate]. This and this answer helped me. But, the problem is it works but, after few hours later when I start my laptop I get the same issue.
I faces the issue whenever I run codes on the . Then, reboot my laptop everything works fine. I am unable to fix the issue permanently. I didn't use wifite after facing the issue that moment
sudo airmon-ng check kill
Output :
Killing these processes
PID Name
1394 wpa_supplicant
sudo service NetworkManager restart
sudo ifconfig wlan0 up
Output : wlan0 : Error while getting interface flags : No such device
sudo iwconfig wlan0 down
Output : wlan0: ERROR while getting interface flags:No such device
sudo ifconfig wlan0 up
Output : wlan0 : ERROR while getting interface flags:No such device
sudo aireplay-ng wlan0
Output : Please specify an attack mode.
"aireplay-ng --help" for help
I was trying to set wlan0 up. But, there was no wlan0 when I run ifconfig. When I restarted after running those commands. wlan0 was working correctly but, I have faced the multiple times. After running wifite few days ago. Even I have faced the issue again now... I think wifite status is keep running or something else is happening to it.
iwconfig
lo no wireless extensions.
eth0 no wireless extensions.
wlan0 IEEE 802.11 ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=15 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:off
wwan0 no wireless extensions.
docker0 no wireless extensions.
ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:7d:19:b4:b6 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether f0:de:f1:da:7d:80 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 20 memory 0xf2500000-f2520000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 28 bytes 1728 (1.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 28 bytes 1728 (1.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
You've already tried killing wpa_supplicant and restarting NetworkManager, but if the entire interface is no longer visible in the outputs of commands iwconfig, ifconfig iw list and/or ip link show, then that won't help.
The problem could be that the WiFi adapter driver has some kind of miscommunication with the hardware. It might be a suspend/hibernate issue, if you use that functionality.
You might want to check the dmesg output to see if there are any error messages related to the WiFi interface. And when the interface is no longer visible to commands like iwconfig etc., then you might try unloading & reloading the driver module for your WiFi interface.
When the wlan0 interface is working correctly, sudo ethtool -i wlan0 | awk '/driver:/{print $2;}' should display the name of the driver module. Make a note of it.
When the wlan0 goes missing again, run sudo modprobe -r <driver module name>, replacing <driver module name> with the actual module name you noted earlier, to unload the module. Then sudo modprobe <driver module name> to re-load it. This will force the driver to re-initialize the WiFi adapter 100% from scratch, hopefully clearing any miscommunication-related error states.
If this causes the WiFi adapter to start working again, and the problem seems to happen whenever you suspend your laptop, then you might need to customize the suspend/resume process to automatically shut down the WiFi adapter and unload its driver on suspend, and reload it on resume. This is generally doable fairly easily on most distributions, but I don't know what would be the recommended method for it for Kali specifically.
Apparently Kali is based on Debian, so putting the following script into /lib/systemd/system-sleep/wifi-workaround.sh and making it executable (chmod a+rx /lib/systemd/system-sleep/wifi-workaround.sh) might do the trick:
#!/bin/sh
# When suspending/resuming, systemd will call executables in /lib/systemd/system-sleep
# with the following parameters:
# $1 = either "pre" or "post"
# $2 = "suspend", "hibernate", "hybrid-sleep" or "suspend-then-hibernate"
INTERFACE=wlan0
DRIVER_MODULE=<driver module name>
case "$1" in
pre)
nmcli device disconnect $INTERFACE
modprobe -r $DRIVER_MODULE
;;
post)
modprobe $DRIVER_MODULE
nmcli device connect $INTERFACE
;;
esac
# Don't stop suspending/resuming even if we fail somehow.
exit 0
Disclaimer: I have not tested this at all, you might need to troubleshoot & adjust this yourself. But I hope you get the idea.
| wlan0 isn't working most of times |
1,413,894,503,000 |
I've been trying to understand the booting process, but there's just one thing that is going over my head..
As soon as the Linux kernel has been booted and the root file system (/) mounted, programs can be run and further kernel modules can be integrated to provide additional functions. To mount the root file system, certain conditions must be met. The kernel needs the corresponding drivers to access the device on which the root file system is located (especially SCSI drivers). The kernel must also contain the code needed to read the file system (ext2, reiserfs, romfs, etc.). It is also conceivable that the root file system is already encrypted. In this case, a password is needed to mount the file system.
The initial ramdisk (also called initdisk or initrd) solves precisely the problems described above. The Linux kernel provides an option of having a small file system loaded to a RAM disk and running programs there before the actual root file system is mounted. The loading of initrd is handled by the boot loader (GRUB, LILO, etc.). Boot loaders only need BIOS routines to load data from the boot medium. If the boot loader is able to load the kernel, it can also load the initial ramdisk. Special drivers are not required.
If /boot is not a different partition, but is present in the / partition, then shouldn't the boot loader require the SCSI drivers, to access the 'initrd' image and the kernel image? If you can access the images directly, then why exactly do we need the SCSI drivers??
|
Nighpher, I'll try to answer your question, but for a more comprehensive description of boot process, try this article at IBM.
Ok, I assume, that you are using GRUB or GRUB2 as your bootloader for explanation. First off, when BIOS accesses your disk to load the bootloader, it makes use of its built-in routines for disk access, which are stored in the famous 13h interrupt. Bootloader (and kernel at setup phase) make use of those routines when they access disk. Note that BIOS runs in real mode (16-bit mode) of the processor, thus it cannot address more than 2^20 bytes of RAM (2^20, not 2^16, because each address in real mode is comprised of segment_address*16 + offset, where both segment address and offset are 16-bit, see "x86 memory segmentation" at Wikipedia). Thus, these routines can't access more than 1 MiB of RAM, which is a strict limitation and a major inconvenience.
BIOS loads bootloader code right from the MBR – the first 512 bytes of your disk – and executes it. If you're using GRUB, that code is GRUB stage 1. That code loads GRUB stage 1.5, which is located either in the first 32 KiB of disk space, called DOS compatibility region, or from a fixed address of the file system. It doesn't need to understand the file system structure to do this, because even if stage 1.5 is in the file system, it is "raw" code and can be directly loaded to RAM and executed: See "Details of GRUB on the PC" at pixelbeat.org, which is the source for the below image. Load of stage 1.5 from disk to RAM makes use of BIOS disk access routines.
Stage 1.5 contains the filesystem utilities, so that it can read the stage 2 from the filesystem (well, it still uses BIOS 13h to read from disk to RAM, but now it can decipher filesystem info about inodes, etc., and get raw code out of the disk). Older BIOSes might not be able to access the whole HD due to limitations in their disk addressing mode – they might use Cylinder-Head-Sector system, unable to address more than first 8 GiB of disk space: http://en.wikipedia.org/wiki/Cylinder-head-sector.
Stage 2 loads the kernel into RAM (again, using BIOS disk utilities). If it's 2.6+ kernel, it also has initramfs compiled within, so no need to load it. If it's an older kernel, bootloader also loads standalone initrd image into memory, so that kernel could mount it and get drivers for mounting real file system from disk.
The problem is that the kernel (and ramdisk) weigh more than 1 MiB; thus, to load them into RAM you have to load the kernel into the first 1 MiB, then jump to protected mode (32-bit), move the loaded kernel to high memory (free the first 1 MiB for real mode), then return to real (16-bit) mode again, get ramdisk from disk to first 1 MiB (if it's a separate initrd and older kernel), possibly switch to protected (32-bit) mode again, put it to where it belongs, possibly get back to real mode (or not: https://stackoverflow.com/questions/4821911/does-grub-switch-to-protected-mode) and execute the kernel code. Warning: I'm not entirely sure about thoroughness and accuracy of this part of description.
Now, when you finally run the kernel, you already have it and ramdisk loaded into RAM by bootloader, so the kernel can use disk utilities from ramdisk to mount your real root file system and pivot root to it. ramfs drivers are present in the kernel, so it can understand the contents of initramfs, of course.
| How does Linux load the 'initrd' image? |
1,413,894,503,000 |
I read through this popular IBM doc (I see it referred quite often on the web) explaining the function of the initial RAM disk.
I hit a wall in conceptualizing how this works though.
In the doc it says
The boot loader, such as GRUB, identifies the kernel that is to be
loaded and copies this kernel image and any associated initrd into
memory
I'm already confused: Does it copy the entire kernel into memory or just part of it?
If the entire kernel is in memory then why do we even need the initial RAM disk?
I thought the purpose of initrd was to be able to have a small generalized kernel image and initrd will install the correct modules in it before the kernel image is loaded. But if the entire kernel is already in memory why do we need initrd?
That also brings up another thing that confuses me - where are the modules that get loaded into the kernel located? Are all the kernel modules stored inside initrd?
|
The entire kernel is loaded into memory at boot, typically along with an initramfs nowadays. (It is still possible to set up a system to boot without an initramfs but that's unusual on desktops and servers.)
The initramfs's role is to provide the functionality needed to mount the "real" filesystems and continue booting the system. That involves kernel modules, and also various binaries: you need at least udev, perhaps some networking, and kmod which loads modules.
Modules can be loaded into the kernel later than just boot, so there's no special preparation of the kernel by the initramfs. They can be stored anywhere: the initramfs, /lib/modules on the real filesystem, in a development tree if you're developing a module... The initramfs only needs to contain the modules which are necessary to mount the root filesystem (which contains the rest).
| Is the entire kernel loaded into memory on boot? |
1,413,894,503,000 |
I am trying to customize the initramfs rescue environment and would like to force the kernel to fail mounting / and drop into the (initramfs) rescue shell, as opposed to single user mode.
How can I do that?
NB: I know how to hook into initramfs-tools to achieve the customization steps, but I need to be able to verify the result.
|
This will drop you into an initramfs shell:
Start your computer. Wait until the Grub menu appears.
Hit e to edit the boot commands.
Append break=mount to your kernel line.
Hit F10 to boot.
Within a moment, you will find yourself in a initramfs shell.
If you want to make this behavior persistent, add GRUB_CMDLINE_LINUX_DEFAULT="break=mount" to /etc/default/grub and run grub-mkconfig -o /boot/grub/grub.cfg.
| How can I force a Ubuntu kernel to fail mounting / and drop into the initramfs rescue shell? |
1,413,894,503,000 |
I have just set up a Gentoo base system (which means I can boot and log in and do stuff with it now). My root partition is in an LVM2 virtual group (with a separated /boot partition). In order to boot I need to pass the parameters below to the kernel:
root=/dev/ram0 real_root=/dev/vg/rootlv init=/linuxrc dolvm
Apparently it is using an initial ramdisk to do something (I guess loading the LVM things) before mounting root. Is there a way that I can put this code into the kernel itself so that no initrd is needed? If not, how can I make the initrd myself?
It might be useful to add that I had tried compiling the kernel for non-LVM root, without initrd and it worked perfectly. Then I tried to put the whole thing under LVM and couldn't get the machine to boot (I guess it cannot deal with the LVM stuff). Then I used the genkernel tool with the --lvm option and it creates the working kernel and initrd that I am currently using.
Now I want to skip genkernel and do everything on my own, preferably without initrd so that the machine will boot somewhat faster (I don't need the flexibility anyway).
|
Simple answer: No. If you want LVM you need an initrd.
But as others have said before: LVMs don't slow your system down or do anything bad in another way, they just allow you to create an environment that allows your kernel to load and do its job.
The initrd allows your kernel to be loaded: If your kernel is on an LVM drive the whole LVM environment has to be established before the binary that contains the kernel can be loaded.
Check out the Wikipedia Entry on initrd which explains what the initrd does and why you need it.
Another note: I see your point in wanting to do things yourself but you can get your hands dirty even with genkernel. Use genkernel --menuconfig all and you can basically set everything as if you would build your kernel completely without tool support, genkernel just adds the make bzImage, make modules and make modules_install lines for you and does that nasty initrd stuff.
You can obviously build the initrd yourself as it is outlined here for initramfs or here for initrd.
| Is it possible to put root in LVM without using initrd? |
1,413,894,503,000 |
I'm running Ubuntu 11.10, which came with kernel version 3.0.0-14. I downloaded and built a kernel from the 3.1.0 branch. After installing the new kernel, I see that my /boot/initrd.img-3.1.0 file is HUGE. It's 114MB, while my /boot/initrd.img-3.0.0-14-generic is about 13MB. I want to get rid of the bloat, which is clearly unnecessary.
When building the new kernel, I copied my /boot/config-3.0.0-14-generic to .config in my build directory, as to keep the configuration of my original kernel. I ran make oldconfig, selected the defaults for all the new options, and then built the kernel.
Looking at the file sizes within each of the initrd cpio archives, I see that all of my .ko modules are larger in size in the 3.1.0 ramdisk, than the 3.0.0-14. I assumed there was an unnecessary debug flag checked in my config file, but I don't see anything different that was not already enabled in the 3.0.0-14 config file.
My /boot/config-3.0.0-14-generic is here:
http://pastebin.com/UjH7nEqd
And my /boot/config-3.0.1 is here:
http://pastebin.com/HyT0M2k1
Can anyone explain where all the unnecessary bloat is coming from?
|
When building the kernel and module using make oldconfig, make and make install, the resulting modules will have debug information available in the files.
Use the INSTALL_MOD_STRIP option for removing debugging symbols:
make INSTALL_MOD_STRIP=1 modules_install
Similarly, for building the deb packages:
make INSTALL_MOD_STRIP=1 deb-pkg
| Why is my initial ramdisk so big? |
1,413,894,503,000 |
After configuring and building the kernel using make, why don't I have vmlinuz-<version>-default.img and initrd-<version>.img, but only got a huge vmlinux binary (~150MB)?
|
The compressed images are under arch/xxx/boot/, where xxx is the arch. For example, for x86 and amd64, I've got a compressed image at /usr/src/linux/arch/x86/boot/bzImage, along with /usr/src/linux/vmlinux.
If you still don't have the image, check if bzip2 is installed and working (but I guess if that were the problem, you'd get a descriptive error message, such as "bzip2 not found").
Also, the kernel config allows you to choose the compression method, so the actual file name and compression algorithm may differ if you changed that kernel setting.
As others already mentioned, initrds are not generated by the linux compilation process, but by other tools. Note that unless, for some reason, you need external files (e.g. you need modules or udev to identify or mount /), you don't need an initrd to boot.
| vmlinuz and initrd not found after building the kernel? |
1,413,894,503,000 |
While reading through the kernel documentation on ramdisk in
ramfs-rootfs-initramfs.txt i was having a doubt like the ramdisk explained there is same as the initrd features described in the post at the-difference-between-initrd-and-initramfs.
Could someone clarify me on this??
And if it is the same, i read that there are many disadvantages for it, but still in my fedora PC, i see
initrd-2.6.29.4-167.fc11.i686.PAE.img
in my boot folder. Is it different from the initrd mentioned above??
UPDATE_EDIT :
In of the articles I even saw a command like
# update-initramfs -u all
update-initramfs: Generating /boot/initrd.img-2.6.18-5-amd64
So how is this initramfs linked to initrd.img ?
|
A ramdisk is a set of blocks that gets copied to an allocated chunk of memory, then treated as a block device. A normal filesystem is created on the ramdisk. The initrd (initial ramdisk) is a ramdisk that is mounted during bootup.
The initramfs is something different. It's a cpio archive of files that is loaded during bootup. The kernel loads the contents into a virtual filesystem it calls rootfs. Unlike a ramdisk, deleting files directly frees memory, and there's no extra filesystem and block layer involved.
Both methods result in files being available to the kernel at boot time before any devices have been loaded, and so in practice you can achieve similar results with both. Older systems use initrd (it was created before initramfs) but modern systems should all be using initramfs. You may still see the word initrd in reference to something that is really an initramfs; it's just naming for compatibility's sake.
| Is Ramdisk and initrd the same? |
1,413,894,503,000 |
How do the md devices get assembled at bootup in Ubuntu? Is /etc/mdadm/mdadm.conf truly the relevant factor here?
My mdadm.conf is sound and I checked that while I was in the rescue CD environment. When running mdadm -A --scan it finds and assigns the device names as desired. The mdadm.conf contains AUTO -all to take out all automatism from assembling the arrays.
What I need to do is to be able to auto-assemble the md devices as outlined in mdadm.conf at boot time or that when assembling it honors the super-minor value for the 0.9 array and the name (apparently <hostname>:<super-minor>) for the 1.2 arrays and does the right thing without mdadm.conf. What puzzle piece am I missing?
I have the following problem. There are two md devices with RAID1 (md0 and md1) and one with RAID6 (md2). I am referring to them by the desired device names. md0 has meta-data version 0.9, the other two have version 1.2. md0 maps to / and the other two are not relevant for booting.
The boot drive is GPT partitioned. There is a glue "BIOS Boot Partition" (sda1) on it. grub-install --no-floppy /dev/sda reports success.
md0 == sda3 + sdb3
md1 == sda2 + sdb2
md2 == sdc + sdd + sde + sdf + sdg + sdh
sda1 and sdb1 are "BIOS Boot Partition" each
GRUB2 is happy with the /boot/grub/devicemap I gave it and I added part_gpt, raid, mdraid09 and ext2 to the modules to preload in GRUB2.
Since I still had my root volume in the rescue environment, I simply mounted everything and then chrooted into it:
mkdir /target
mount /dev/md0 /target
mount -o bind /dev /target/dev
mount -o bind /dev/pts /target/dev/pts
mount -o bind /sys /target/sys
mount -o bind /proc /target/proc
chroot /target /bin/bash
From there I reset the super-minor on md0 (with meta-data 0.9) and the name on md1 and md2. I also verified that it worked using mdadm --detail ....
Other than that I adjusted /etc/default/grub, run update-grub and also grub-install --no-floppy /dev/sda and grub-install --no-floppy /dev/sdb.
After that, when booting, I am always dropped into the initramfs rescue shell, however, because the root file system could not be mounted. The reason, after checking /proc/mdstat appears to be that the respective md device doesn't even get assembled and run. Not to mention that the other two (meta-data version 1.2) drives receive a device number somewhere in the 125..127 range.
Note: GRUB2 comes up from the boot disk. So at the very least it has been embedded correctly. The issue is the transition from the initial rootfs to the proper root file system.
|
Basic Boot Process
Grub
Grub reads its disk, md, filesystem, etc. code from the MBR.
Grub finds its /boot partition, and reads the rest of itself out of it. Including the config, and any modules the config specifies need loading.
Grub follows the instructions in the config, which typically tell it to load a kernel and initramfs into memory, and execute the kernel.
There is a fallback mode, for when Grub can't actually read the filesystem—either because there wasn't enough space to embed all that code in the boot record, or because it doesn't know the filesystem or layers under it. In this case, GRUB embeds a list of sectors, and reads code from them. This is much less robust, and best avoided. It may even be able to do kernel and initramfs like that (not sure).
Kernel
The kernel then takes control, and does a lot of basic hardware init. This stage is fairly quick. Next, the kernel unpacks the initramfs to a tmpfs, and looks for a /init on that tmpfs. It then executes (in the normal sense, the kernel is fulling running at this point) /init. This is, by the way, a plain old shell script.
Initramfs
You can extract the initramfs by hand by doing something like mkdir /tmp/foo; cd /tmp/foo; zcat /boot/initrd.img-3.8-trunk-amd64 | cpio -idmv.
The initramfs is responsible for loading all the drivers, starting udev, and finding the root filesystem. This is the step that is failing for you—it can't find the root filesystem, so it bails out.
Once the initramfs has finished, it has the root filesystem mounted, and hands over control to /sbin/init.
System boot
At this point, your init takes over—I think Ubuntu is using upstart currently.
What's Broken
I'm not entirely sure what's broken (part, I confess, because I'm much more familiar with how it works on Debian than Ubuntu, though its similar), but I have a couple of suggestions:
The initramfs has its own copy of mdadm.conf. You may just need to run update-initramfs -u to fix it.
Look at the boot messages. There may be an error. Get rid of 'quiet' and 'splash' and maybe add 'verbose' to your kernel line to actually see them.
Depending on storage used, you may need to set the rootdelay parameter.
When you're dumped to the shell prompt, you don't have a lot of commands, but you do have mdadm. Try to figure out what went wrong. If you fix the problem, boot can continue.
| Ubuntu: How do the md devices get assembled at bootup? |
1,413,894,503,000 |
I'm running Debian Bookworm on a TS412 (QNAP); it stores the kernel & initrd in flash. It has a total of 16MB of flash. So even after tweaking with the MD partitions the best I can get is a 12MB initrd . I'm using xz compression. But even so, the initial initrd was 12.5MB. I know the common fix is to reduce modules, but they are not the real issue.
2984 .../usr/lib/modules
6036 .../usr/share
18824 .../usr/lib/arm-linux-gnueabi
Looking in arm-linux-gnueabi it had stuff like libX11... This machine does not even have a console (even getting a serial line is difficult) it certainly does not need "X".
So I removed lots of packages totally (apt-get remove ...) in fact rather more than I should really. But the result was a much smaller initrd (about 5MB IIRC) which boots and runs just fine.
Problem is, if I ssh onto the box and run say emacs(1) it'd be nice to project the GUI version back to my normal desktop (which has lots of memory and big displays, etc.) but this would require installing the X client libraries on the TS412.
Now I don't see why just because I have the package with the X client libraries installed, that a copy needs to be kept on initrd, they aren't needed during boot. Is there a way to limit other stuff from getting onto initrd, not just modules (which are not the culprit)
I've already tried document searches for guides to limit initrd.
|
There could be a binary intended to display graphical information during boot that would pull libraries it depends upon in the initramfs file.
One such binary available on most architectures, including armel is the label.so plugin provided by plymouth-label as a plugin for Plymouth in order to have a graphical display with text during boot. This plugin depends on various X11 libraries and is used to render text. When this plugin is added to the initramfs all the libraries it depends upon are also added so it can be used in the boot phase. This is advertised by the package's dependencies: plymouth-label depends on libcairo2 which itself depends on various X11 library packages including libx11-6 providing the library libX11.so.6.
The initramfs hook adding label.so would be /usr/share/initramfs-tools/hooks/plymouth:
PLUGIN_PATH="$(plymouth --get-splash-plugin-path)"
case "${THEME_NAME}" in
text|details|tribar)
PLUGINS="text.so details.so"
;;
*)
PLUGINS="text.so details.so label.so"
;;
esac
[...]
for PLUGIN in ${PLUGINS}
do
if [ -f ${PLUGIN_PATH}/${PLUGIN} ]
then
copy_exec ${PLUGIN_PATH}/${PLUGIN}
else
[...]
copy_exec is a shell function (provided by initramfs-tools-core) that will pull the dependencies whenever needed in addition to copying the binary, relying on ldd to discover what's needed.
so it appears it would be pulled only when a non-text setting is used in Plymouth... in order to display text.
As a QNAP's main purpose is not video, having plymouth installed and especially this plugin should be avoided, avoiding X11 libraries to be pulled in the initramfs file.
I fail to see any other cause for this behavior. There could be an other similar package causing this behavior for similar reasons.
| Eliminate inclusion of X11 libs in initrd |
1,413,894,503,000 |
Can the initramfs image be compressed by a method other than gzip, such as lzma?
|
Yes. I use in-kernel initrd and it offers at least the following methods:
None (as it is compressed with kernel)
GZip
BZip
LZMA (possibly zen-only)
You can use it on external file and with LZMA (at least on Ubuntu).
Wikipedia states that Linux kernel supports gzip, bzip and lzma (depending, of course, what algorithms are compiled in).
| Can the initramfs image use a compression format other than gzip? |
1,413,894,503,000 |
I want to make a very minimal linux os which only have a terminal interface and basic commands/applications (busybox is my choice for commands/apps). I don't want the installation option on my os. I just want it to be booted and run completely from RAM. I'm planning to use ISO-Linux as bootloader. No networking, no virtualization support, no unnecessary drivers, etc. I want it to be very very basic os. I've downloaded the latest stable kernel (v4.5) source code from kernel.org and the build environment ready.
My one more confusion is that does a kernel by default has any user interface (shell, terminal, ...) where i can type commands and see output?
|
Technically you can achieve this.
Though, kernel do not have any built-in user-interface.
You need to follow steps as:
1. Create a initramfs with static busybox and nothing else.
This initramfs will have few necessary directories: like proc, sys, tmp, bin, usr, etc
2. Write a "/init" script, whose main job will be:
a. mount the procfs,tmpfs and sysfs.
b. Call busybox's udev i.e. mdev
c. Install the busybox command onto virtual system by executing busybox install -s
d. Calling /bin/sh
3. Source the initramfs directory while compiling the kernel. You can do so by flag: CONFIG_INITRAMFS_SOURCE
4. Compile your kernel.
5. Boot off this kernel and you will get the shell prompt with minimal things.
Though, I write above notes in a very formal way. You can fine tune it the way you desire.
UPDATE:
Follow this link for some guidelines.
| How to make a minimal bootable linux (only with terminal) from kernel source code? [duplicate] |
1,413,894,503,000 |
I'm currently learning the Linux environment, and decided to manually install the Apache server. For educational purposes, I've compiled it into:
/server/apache
The http.conf location is configured correctly. It works -- I can open up a browser and navigate to localhost and see the "It works" message. But how does one goes about adding Apache into Ubuntu's startup so I won't have to do:
sudo /server/apache/bin/apachectl start
all the time? Can somebody explain how does one goes into adding programs to the Ubuntu startup (10.10 64 bit)?
|
The easiest way is to take the Apache startup script in Ubuntu's Apache package, and replace /usr/sbin/apachectl by /server/apache/bin/apachectl.
If it's a learning exercise, you have several options (from most flexible to least flexible):
Start Apache through Upstart. You have to write a file /etc/init/my_apache.conf. Given the state of Upstart documentation, I recommend reading existing examples and the man pages in parallel.
Start Apache through a SysV script: an executable script in /etc/init.d that starts, stops, restarts or reloads the Apache configuration depending on whether its first (and sole) argument is start, stop, restart, or reload (with force-reload as an alias for reload). To have the script start on boot, run update-rc.d. See also the Ubuntu Bootup Howto.
Start Apache from /etc/rc.local.
| Add Apache to Ubuntu's startup |
1,413,894,503,000 |
In How do I extract the filesystem image from vmlinux.bin? and https://wiki.gentoo.org/wiki/Custom_Initramfs#Salvaging methods are presented for getting and unpacking an embedded initramfs/initrd included in the kernel image.
Now I would like to insert the modified file system (cpio + possibly packed using e.g. lzma) into the kernel executable without having to recompile it. Would it be possible to modify the ELF image of the kernel in this way? If so then how? Would I need to keep something in respect if I were to simply replace the bytes in-place (maybe some hash?)?
objdump-h Output:
vmlinux.64.orig: file format elf64-big
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 004162b8 ffffffff80100000 ffffffff80100000 00010000 2**7
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 __ex_table 000063a0 ffffffff805162c0 ffffffff805162c0 004262c0 2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .notes 00000024 ffffffff8051c660 ffffffff8051c660 0042c660 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .rodata 0041f700 ffffffff8051d000 ffffffff8051d000 0042d000 2**8
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .pci_fixup 00000d40 ffffffff8093c700 ffffffff8093c700 0084c700 2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 __ksymtab 0000a430 ffffffff8093d440 ffffffff8093d440 0084d440 2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
6 __ksymtab_gpl 00004ff0 ffffffff80947870 ffffffff80947870 00857870 2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
7 __ksymtab_strings 00010f14 ffffffff8094c860 ffffffff8094c860 0085c860 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
8 __init_rodata 00000500 ffffffff8095d778 ffffffff8095d778 0086d778 2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
9 __param 00001388 ffffffff8095dc78 ffffffff8095dc78 0086dc78 2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
10 .data 000508c0 ffffffff80960000 ffffffff80960000 00870000 2**14
CONTENTS, ALLOC, LOAD, DATA
11 .init.text 0002b084 ffffffff809b1000 ffffffff809b1000 008c1000 2**5
CONTENTS, ALLOC, LOAD, READONLY, CODE
12 .init.data 00bc6d78 ffffffff809dc088 ffffffff809dc088 008ec088 2**3
CONTENTS, ALLOC, LOAD, DATA
13 .exit.text 000019e0 ffffffff815a2e00 ffffffff815a2e00 014b2e00 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
14 .data.percpu 00003680 ffffffff815a5000 ffffffff815a5000 014b5000 2**7
CONTENTS, ALLOC, LOAD, DATA
15 .bss 00068fb0 ffffffff815b0000 ffffffff815b0000 014b8680 2**16
ALLOC
16 .mdebug.abi64 00000000 ffffffff81618fb0 ffffffff81618fb0 014b8680 2**0
CONTENTS, READONLY
17 .comment 0000cd74 0000000000000000 0000000000000000 014b8680 2**0
CONTENTS, READONLY
18 .gnu.attributes 00000010 0000000000000000 0000000000000000 014c53f4 2**0
|
As mentioned in the answer to a similar question about replacing ELF sections discussed at reverseengineering.se simply using dd might be enough under some circumstances apart from the new archive not being larger, e.g. whether there are relocations.
| Repack the filesystem image from vmlinux.bin (embedded initramfs) without rebuilding? |
1,413,894,503,000 |
Is it possible to boot linux without a initrd.img ? I am planning to add default drivers as a part-of-kernel itself and avoid initrd completely.
What are the modules that should be made part-of-the-kernel instead of loadable modules ?
|
It is, unless your root volume is on an LVM, on a dmcrypt partition, or otherwise requires commands to be run before it can be accessed.
I haven't used an initrd on my server in years. You need at a minimum these modules built in:
the drivers of whatever controller where your root volume disk lives
the drivers necessary to "get to" that like PCI, PCIe support, USB support, etc.
the modules that run the filesystem mounted on it
It's also a very good idea to build in your network card drivers as well.
I've found that lspci/lsmod can help you here from your currently running kernel, look at what's there and use the make menuconfig search option before compiling to find where to enable the modules.
| Booting without initrd |
1,413,894,503,000 |
This is mostly aimed at Debian/Ubuntu, but I feel savvy enough on a variety of distros to be able to adapt the solution for one distro to another.
Here's my scenario. There are a few situations when the boot process will drop you to the shell (usually busybox) of the initrd. Most notably whenever you run a hardware RAID for which drivers have to be rebuilt for each and every new kernel revision. I'd like to be able to access the rescue system the same way as I would access the fully booted system.
I reckon it'd be possible to put static builds of the shell(s) and sshd (OpenSSH or dropbear) into the initrd and have been looking for an existing solution that I can adjust to my needs.
Assuming there is no existing solution (since I have searched for quite a while) what do I need to consider aside from using static builds where possible (or supply the libs)? Is it reasonable to simply cache a static build of dropbear and use /etc/initramfs-tools/hooks to embed that along with a "converted" OpenSSH sshd_config and the original host keys?
|
Ubuntu 16.04 contains a package called dropbear-initramfs which is supposed to provide this feature.
Lightweight SSH2 server and client - initramfs integration dropbear
is a SSH 2 server and client designed to be small enough to be used
in small memory environments, while still being functional and secure
enough for general use.
It implements most required features of the SSH 2 protocol, and other
features such as X11 and authentication agent forwarding.
This package provides initramfs integration.
The only items I needed to adjust in addition to installing said package where:
Uncomment the commented out DROPBEAR=y inside /etc/initramfs-tools/conf-hooks.d/dropbear
Convert my existing host keys (see below)
Create and populate /etc/initramfs-tools/root/.ssh/authorized_keys. For this I opted to bind-mount /root/.ssh onto /etc/initramfs-tools/root/.ssh
A final update-initramfs -u -k all re-created all the initrd images
To convert the keys I ran these commands:
/usr/lib/dropbear/dropbearconvert openssh dropbear /etc/ssh/ssh_host_rsa_key /etc/initramfs-tools/etc/dropbear/dropbear_rsa_host_key
/usr/lib/dropbear/dropbearconvert openssh dropbear /etc/ssh/ssh_host_dsa_key /etc/initramfs-tools/etc/dropbear/dropbear_dss_host_key
/usr/lib/dropbear/dropbearconvert openssh dropbear /etc/ssh/ssh_host_ecdsa_key /etc/initramfs-tools/etc/dropbear/dropbear_ecdsa_host_key
Note: the source and target file names differ. So don't make assumptions here. Also, /usr/lib/dropbear isn't in my PATH, so I needed to give the full path to execute dropbearconvert.
| Are there any canned solutions for running sshd in the initrd? |
1,413,894,503,000 |
I know that it's possible to extract from a linux kernel the embedded initramfs cpio. I want to know if the reverse operation is possible; i.e., given both a compiled kernel and initramfs archive, how does one combine them?
I'm trying to achieve the same effect of this kernel config...
CONFIG_EFI=y
CONFIG_EFI_STUB=y
...
CONFIG_FB_EFI=y
...
CONFIG_CMDLINE_BOOL=y
CONFIG_CMDLINE="root=..."
...
CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE="my_initrd.cpio"
...without actually configuring and/or compiling the kernel.
References:
http://www.kroah.com/log/blog/2013/09/02/booting-a-self-signed-linux-kernel/
|
Here is my solution:
you can create a combined .efi image
with kernel, command line and initramfs inside,
called a "unified kernel image".
Reference: Preparing a unified kernel image – ArchWiki.
You might want to focus on the “Manually” subsection.
| How to combine linux kernel and initrd without compiling? |
1,413,894,503,000 |
pivot_root() moves the root filesystem of the calling process to the directory put_old and makes new_root the new root filesystem of the
calling process.
The typical use of pivot_root() is during system startup, when the system mounts a temporary root filesystem (e.g., an initrd), then mounts
the real root filesystem, and eventually turns the latter into the current root of all relevant processes or threads.
pivot_root() may or may not change the current root and the current
working directory of any processes or threads which use the old root
directory. The caller of pivot_root() must ensure that processes with
root or current working directory at the old root operate correctly in
either case. An easy way to ensure this is to change their root and
current working directory to new_root before invoking pivot_root().
The paragraph above is intentionally vague because the implementation
of pivot_root() may change in the future. At the time of writing,
pivot_root() changes root and current working directory of each process
or thread to new_root if they point to the old root directory. This is
necessary in order to prevent kernel threads from keeping the old root
directory busy with their root and current working directory, even if
they never access the filesystem in any way. In the future, there may
be a mechanism for kernel threads to explicitly relinquish any access
to the filesystem, such that this fairly intrusive mechanism can be
removed from pivot_root().
...
BUGS
pivot_root() should not have to change root and current working direc‐
tory of all other processes in the system.
Some of the more obscure uses of pivot_root() may quickly lead to
insanity.
-- man pivot_root, Linux man-pages 4.15
I'm working on a case where there are multiple processes running at when pivot_root() is called.
The manpage doesn't seem very clear about how both possible implementations of pivot_root() can handle the case with multiple processes. Let's say we have two processes, S(ystemd) and P(lymouth). Currently, both P and S change their root and working directory to new_root, and then S calls pivot_root(). With the current implementation, this works fine.
Say both S and P "change their root directory" before pivot_root(), using chroot(). But, as man chroot tells us, it is possible to leave a chroot() jail if you are root (mkdir foo; chroot foo; cd ..; chroot .). It seems clear that processes have two associated roots:
their current chroot
the root of their mount namespace
After pivot_root(), S must observe that the root of its mount namespace is equal to its current chroot. Because if there was a deeper root filesystem that it could escape to at a future point, then that root filesystem would be busy and could not be unmounted. I think allowing the old root filesystem to be unmounted was the main purpose of pivot_root().
Currently, P observes the same thing - because it is in the same mount namespace as S.
It sounds like the alternative implementation of pivot_root() would put the calling process in a new, altered mount namespace. Is that a valid reading?
(I note this alternative implementation would make /sbin/pivot_root mostly pointless).
I believe the original pivot_root() actually predates mount namespaces. Do we know if this plan for an alternative implementation of pivot_root(), anticipated the need for some of the features of mount namespaces, or was this requirement overlooked?
(I note that mount namespaces also sound very much like a "mechanism for kernel threads to explicitly relinquish any access
to the filesystem", e.g. kernel threads could do the equivalent of pivot_root() into an empty tmpfs).
|
It sounds like the alternative implementation of pivot_root() would put the calling process in a new, altered mount namespace. Is that a valid reading?
No. IMO this is not very clear, but there is a much more consistent and correct reading.
The essential part of pivot_root(), which must be the same in either implementation, is:
pivot_root() moves the root filesystem of the calling process to the directory put_old and makes new_root the new root filesystem of the calling process.
The essential part of pivot_root() is not limited only to the calling process. The operation described in this quote works on the mount namespace of the calling process. It will affect the view of all the processes in the same mount namespace.
Consider the effect the essential change has on such a second process - or kernel thread - whose working directory was the old root filesystem. Its current directory will still be the old root filesystem. This will keep the /put_old mount point busy, and so it will not be possible to unmount the old root filesystem.
If you control this second process, you resolve this, as per the manpage, by setting its working directory to new_root before pivot_root() is called. After pivot_root() is called, its current directory will still be the new root filesystem.
So process S(ystemd) has been configured to signal process P(lymouth), to change working directory before S calls pivot_root(). No problem. But, we also have kernel threads, which start in /. The current implementation of pivot_root() takes care of the kernel threads for us; it is equivalent to setting the working directories of kernel threads and any other process to new_root before the essential part of pivot_root().
Except, the current implementation of pivot_root() only changes the working directory of a process if the old working directory was /. So it's actually quite easy to see the difference this makes:
$ unshare -rm
# cd /tmp # work in a subdir instead of '/', and pivot_root() will not change it
# /bin/pwd
/tmp
# mount --bind /new-root /new-root
# pivot_root /new-root /new-root/mnt
# /bin/pwd
/mnt/tmp # see below: if pivot_root had not updated our current chroot, this would still show /tmp
v.s.
$ unshare -rm
# cd /
# /bin/pwd
/
# ls -lid .
2 dr-xr-xr-x. 19 nfsnobody nfsnobody 4096 Jun 13 01:17 .
# ls -lid /newroot
6424395 dr-xr-xr-x. 20 nfsnobody nfsnobody 4096 May 10 12:53 /new-root
# mount --bind /new-root /new-root
# pivot_root /new-root /new-root/mnt
# /bin/pwd
/
# ls -lid .
6424395 dr-xr-xr-x. 20 nobody nobody 4096 May 10 12:53 .
# ls -lid /
6424395 dr-xr-xr-x. 20 nobody nobody 4096 May 10 12:53 /
# ls -lid /mnt
2 dr-xr-xr-x. 19 nobody nobody 4096 Jun 13 01:17 /mnt
Now I understand what's happening with the working directory, I find it easier to understand what's happening with chroot(). The current chroot of the process which calls pivot_root() may be a reference to the original root filesystem, just as its current working directory may be.
Note, if you do chdir()+pivot_root() but forgot to chroot(), your current directory would be outside your current chroot. When your current directory is outside your current chroot, things get quite confusing. You probably don't want to run your program in this state.
# cd /
# python
>>> import os
>>> os.chroot("/newroot")
>>> os.system("/bin/pwd")
(unreachable)/
0
>>> os.getcwd()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 2] No such file or directory
>>> os.system("ls -l ./proc/self/cwd")
lrwxrwxrwx. 1 root root 0 Jun 17 13:46 ./proc/self/cwd -> /
0
>>> os.system("ls -lid ./proc/self/cwd/")
2 dr-xr-xr-x. 19 root root 4096 Jun 13 01:17 ./proc/self/cwd/
0
>>> os.system("ls -lid /")
6424395 dr-xr-xr-x. 20 root root 4096 May 10 12:53 /
0
POSIX does not specify the result of pwd or getcwd() in this situation :). POSIX gives no warning that you might get an "No such file or directory" (ENOENT) error from getcwd(). Linux manpages point out this error as being possible, if the working directory was unlinked (e.g. with rm). I think this is a very good parallel.
| Did the pivot_root() documentation anticipate the feature of mount namespaces? |
1,413,894,503,000 |
I'm using an Ubuntu Server (13.04) Minimal installation (with the Xubuntu Metapackage as a desktop environment, if that matters) on x86_64 on my Samsung notebook. I'm currently forced to use the no-longer-maintained version of the proprietary AMD graphics driver (fglrx-legacy) as the open-source "radeon" driver heats the card 15°C more in idle.
That's why I'd really like to try kernel 3.11 with the new power management features for AMD cards. The problem is, once I install a mainline kernel the system freezes after selecting the kernel in Grub with the messages:
Loading Linux 3.11.0-laptop ...
Loading initial ramdisk ...
And nothing happens. How can I find out what's wrong? Are there any logs from that early in the boot process stored somewhere?
Some more information: The system works perfectly with the Ubuntu Raring Kernel self-compiled from Git (which is based on 3.8). It doesn't work with mainline Kernel 3.9 or 3.10 (same problem). I also tried a pre-compiled "generic" version of 3.10, doesn't work either. I have 4 partitions on the hard drive: /boot (unencrypted), /, /home and swap (all LUKS/dm-crypt encrypted). The notebook is a Samsung NP-R522H. The GPU is a Mobility Radeon HD 4650.
|
Sorry, I totally forgot this question.
The solution back then was to use the Saucy (Ubuntu 13.10) Kernel, which is based on 3.11, instead of the vanilla/mainline one. Some changes probably broke compatibility, at least with my combination of hardware and software.
| Kernel freezes on loading ramdisk. How to find out what's wrong? |
1,413,894,503,000 |
I wanted to see what files are added on top of ISO 9660 when LiveUSB Linux is running. When booted with persistence upper and work folders are on USB drive clearly seen. I run mount on Linux booted from LiveUSB "usual way" (w/out persistence) and saw / is mounted via overlayfs and upperdir=/cow/upper. But sudo ls /cow gives no such file or directory.
Where is /cow and how to see its contents?
Added 1:
I was able to extract contents of initrd from liveUSB via unmkinitramfs (see https://unix.stackexchange.com/a/495524/446998)
$ find . -type f -exec bash -c 'cat {} | grep "/cow/upper" && ls -l {}' \;
if [ ! -d /cow/upper ]; then
mkdir -p /cow/upper
/cow/lost+found|/cow/upper|/cow/log|/cow/crash|/cow/install-logs-*) continue ;;
mv "$cow_content" /cow/upper
mount -t overlay -o "upperdir=/cow/upper,lowerdir=$mounts,workdir=/cow/work" "/cow" "$rootmnt" || panic "overlay mount failed"
-rw-r--r-- 1 alex alex 33834 Jun 24 2020 ./main/scripts/casper
Next step I envision is to understand how /cow is created because is not see in contents of initrd
|
// Experience based on kubuntu 22 lts livecd
after chroot
the last step of ramdisk (/cdrom/casper/initrd) is
run-init {rootmnt}" "${init}" "$@"
which do something like
chroot {rootmnt}" "${init}" "$@"
after that step it may affect the observation of the original mount point.
before chroot
Fortunately there are ways to pause at an interactive shell before chrooting (press ctrl+d or exit to continue)
kernel boot cmdline args
break=top,premount,mount,mountroot,bottom,init
may do the trick.
//BTW: manjaro 22 only support break=premount (same as break=y)
or break=postmount, not support multiple values compound with ,
also another cmdline args might help
debug or debug=y
which turn on detail log during ramdisk running
// boot args can be edit at grub menu by press e
// those information comes from reading the ramdisk script
in ramdisk
you already unmkinitramfs and found
scripts/casper
which handle casper-rw persistence things
./scripts/casper
setup_overlay() {
image_directory="$1"
rootmnt="$2"
# Mount up the writable layer, if it is persistent then it may well
# tell us what format we should be using.
mkdir -p /cow
cowdevice="tmpfs"
cow_fstype="tmpfs"
cow_mountopt="rw,noatime,mode=755"
# Looking for "$(root_persistence_label)" device or file
if [ -n "${PERSISTENT}" ]; then
cowprobe=$(find_cow_device "$(root_persistence_label)")
if [ -b "${cowprobe}" ]; then
cowdevice=${cowprobe}
cow_fstype=$(get_fstype "${cowprobe}")
cow_mountopt="rw,noatime"
else
[ "$quiet" != "y" ] && log_warning_msg "Unable to find the persistent medium"
fi
fi
mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || panic "Can not mount $cowdevice on /cow"
code here determine the persistence partition, and mount it
keep /cow after chroot
in ramdisk shell, after /cow /root ready
mkdir /root/_cow
mount -o bind /cow /root/_cow
then after chroot into system, /_cow can access the original outer /cow
| Where is /cow for Linux booted from LiveUSB? |
1,413,894,503,000 |
I'm using clonezilla-1.2.12 and need to add the Broadcom firmware to the initrd so it can netboot.
(clonezilla is debian-based and debian no longer includes the firmware blobs as they're non-free. Naturally then clonezilla doesn't either.)
(I can't use the Ubuntu-based clonezilla as Ubuntu has a bug in it where the Broadcom 5708 chipset Just Doesn't Work.)
I have what seems like a good process for doing so:
~# mkdir /tmp/cz-newinitrd
~# cd /tmp/cz-newinitrd
/tmp/cz-newinitrd# xzcat /media/CLONEZILLA/live/initrd.img.orig > initrd
/tmp/cz-newinitrd# (cd /; find lib/firmware/bnx2 | cpio -o -H newc --append -O /tmp/cz-newinitrd/initrd)
/tmp/cz-newinitrd# xz -c initrd > /media/CLONEZILLA/live/initrd.img
BUT linux refuses to recognize the redone initrd:
I also tried making a single cpio archive (without using --append) and got the same result.
If I completely skip modifying the archive and just uncompress/recompress I still get the same result.
What is going wrong here?
|
The guilty culprit here was the xz step. Looks like the version of xz on my desktop was doing something incompatible with the decompressor in the clonezilla kernel.
Switching to gzip makes it works just fine.
According to Steven Shiau, it's necessary to use --check=crc32 when recompressing the initrd with xz. After doing that, everything works fine!
| Adding files to initrd makes linux not be able to read it |
1,413,894,503,000 |
The file shows 56 blocks as the size. I am using the system Ubuntu 16.04 and I need a solution that does not require me to update the kernel.
|
Although it may be named initrd, it is actually an initramfs. That means, it can be a concatenation of multiple cpio archives, each of which may or may not be compressed. You may have managed to extract just the first part.
Proper procedure for extracting an initramfs file
More specifically, the first cpio part is usually an "early microcode update", which for Intel processors has a pathname kernel/x86/microcode/GenuineIntel.bin. If you just run cpio -iv /boot/initrd.img-<kernel version>, this is all you get extracted.
(The microcode is typically not compressed because it's encrypted and so won't compress much at all.)
To fully extract a modern initramfs in a Debian/Ubuntu system, you should use the unmkinitramfs command.
If that command is not available for some reason, you can do it manually like this:
mkdir /some/temporary/directory
cd /some/temporary/directory
cat /boot/initrd.img-$(uname -r) | (cpio -iv; zcat | cpio -iv; file -)
assuming that the initramfs has only two parts.
The idea is that the cat command will output the contents from the beginning to the end to the commands within the parentheses. Within them, the first cpio will take the beginning of the file and extract the early microcode update. Once it finishes, the next command will pick up from where the first command left off. When the second, compressed cpio archive ends, the file - command checks to see whether or not there is still more to come.
If the last line of extraction output is not
/dev/stdin: empty
...then you'll know there is a further part in the initramfs file, and the file command output tells you whether it's compressed or not. Then add another cpio -iv; or zcat | cpio -iv; element within the parentheses just before the filecommand.
For example, to extract a three-part initramfs with two compressed parts after the early microcode update:
cat /boot/initrd.img-$(uname -r) | (cpio -iv; zcat | cpio -iv; zcat | cpio -iv; file -)
If your initrd is really only 56 blocks in size
In this case, the initrd creation process may have failed. You can use
sudo update-initramfs -u
to tell the system to regenerate it based on your current kernel and modules. This is also a good command to run after any configuration changes that may affect things that need to happen early in the system start-up, before the real root filesystem is mounted.
| My initrd has only one directory, after decompressing, namely 'kernel' |
1,413,894,503,000 |
The first answer of 'Why does Linux use an Initial Ram Disk at boot?' states that the initrd/initial ram filesystem is used to provide drivers to mount the real root filesystem. It also says that it is possible to patch these drivers into the kernel so an initrd or initial ram filesystem is not required, but gave no explanation of how. How can I patch the kernel (latest version) to mount an EXT4 filesystem at root without the aid of the initrd, and will this solution support UUIDs?
|
You don't need to patch anything. You just need to configure and compile the kernel by yourself. This is advanced task so it is not for begginers. The trick is to configure the kernel to support just your hardware and compile everything inside the kernel and not as a module (at least the drivers necessary for booting: disk controller, filesystem, …).
There are plenty of tutorials, how to configure and compile your kernel
Gentoo https://wiki.gentoo.org/wiki/Kernel/Configuration
Arch https://wiki.archlinux.org/index.php/Kernels/Traditional_compilation
Ubuntu https://help.ubuntu.com/community/Kernel/Compile
So just google "kernel compile {your distro}". It is important to use correct tutorial for your distro. Distro you are using may expect some functionality available only in "distro" kernel and not in "vanilla" kernel. Correct tutorial will point you to correct sources.
You can use UUIDs in /etc/fstab but not in GRUB after removing initrd/initramfs.
For example, I'm using Gentoo and I have never used initrd/initramfs. Everytime the new kernel is available, I must configure and compile it by myself. I'm using grub with root=/dev/sdb4 kernel parameter but in fstab I'm using UUIDs.
| Patching the kernel to allow booting without initrd |
1,413,894,503,000 |
How can i create initrd image for a new(experimental) kernel without actually installing it.
(Existing tools to create initrd based on config and details from installed kernel.)
Say i compile a new kernel with experimental features turned on, i have this in another separate partition. I would like to boot into this kernel, for that will old initrd work ?
if i want to create a new initrd.img for new kernel without actually installing kernel, how can i do it ?
BTW, can someone clarify about initramfs ? will it be useful for my scenario ?
|
Creating an initrd doesn't have anything to do with installing a kernel. All you do is to create a file structure for the initrd, copy the required files, write the init script and package all of that into a cpio archive. I used the instructions in the Gentoo Wiki to make my initrd. Some distributions make tools to generate initrds, and for that you will have to name your distro. For example, Arch has mkinitcpio.
initramfs is just another (newer) implementation of the initial ramdisk. I don't know for sure, but I think modern distributions all use initramfs. When you see "initrd", it may be a shorthand for "initial ramdisk", and thus it covers both initrd and initramfs.
| Creating new initrd without installing kernel |
1,413,894,503,000 |
Currently I am learning about linux booting process.Here i noticed that the initrd will create temporary root file system that includes drivers(LVM, NFS, etc) which are required by kernel.After that kernel will make use of that drivers and it will mount real root file system.
Here my question is why not kernel itself should include the necessary drivers inside it and why it depends on initrd ?
|
See also answers on these questions:
Why don't we include File System drivers in the kernel itself instead of using Initrd/Initramfs
Why do we need initramfs and initrd
1. Why not kernel itself should include the necessary drivers inside it
Firstly, know that kernel memory is not demand-paged. That would be a circular dependency. If you page out your disk driver to the disk when you're low on memory, you can't load it back later.
(And inside the Linux kernel, we don't try to define some higher layer which isn't involved in the storage path and can safely be paged out. Allegedly this is possible: Windows did it. I don't know what this higher layer is supposed to be though. Maybe it is defined dynamically. Or maybe Windows has the luxury of not supporting strange ideas like swap-over-NFS).
Instead, we support loading modules. If we don't need NFS on this particular computer, we don't have to load it.
In a modern distribution this saves on the order of a hundred megabytes of RAM overall. (Look at the space taken by /lib/modules/$VERSION/. Note that in modern distributions, the modules are compressed e.g. .xz files).
2. and why it depends on initrd
While kernel modules are the more obvious reason for the initrd, there is a second aspect.
It lets userspace build arbitrarily complex storage stacks to access the root filesystem. E.g. getting an IP address using DHCP, to support NFS, or prompting for a disk encryption passphrase.
Again, the kernel tries not to bloat too much e.g. with user interface code.
Memory usage is only one reason. The kernel/userspace division is overloaded with a number of purposes. E.g. the kernel can be one project and work specifically on kernel things. Userspace can be anything; it could be a "normal" Linux distribution, or it could be an entirely independent project like the Android OS.
This is different from other OS's, e.g. the BSDs maintain kernel + core userspace together. This is illustrated by BSDs being able to handle the 2038 problem with a single flag day conversion of both kernel and userspace.
| Why kernel cannot do the initrd/initramfs job itself? [closed] |
1,413,894,503,000 |
I've read that I can boot the kernel without initrd, and I've also read that additional modules are loaded during the initrd stage -- as I understand it, for necessary drivers that weren't included in the kernel.
If I build the kernel with make defconfig && make, on what kind of hardware can I expect the kernel to boot in? A reasonably modern desktop? Virtualbox?
When would I really need initrd/initramfs?
I'm trying to put together a minimal system to tets out on Virtualbox, and if possible, I'd like to keep things simple and not use an initrd.
|
You can boot without initrd on any hardware. I never use it myself on desktops/laptops and home servers, because it just adds to boot time. The only situation where I've found it really necessary so far, is when your root filesystem is on an LVM (but I may be in error - there might be some way to go about this also).
If you want your setup to be fast and simple, you should first of all try to remove all the unnecessary stuff from your kernel configuration. There are two general ways you can do that while configuring your kernel:
strip down - try to get rid of all the unnecessary modules and options
or
build up - take a minimal config and add in just the stuff you need
I personally recommend the second option - simply because it takes less time and you avoid being overwhelmed by uncertainty about all the options. For a great starting point, you can pick an adequate Pappy's kernel seed. You can find more information about those on his webpage. With this approach, a general tip from my side is to first run lspci -knn, which will tell you, what modules are currently used by most of your hardware.
| When would an initrd be necessary? |
1,413,894,503,000 |
The Linux kernel contains very minimal code that is necessary to boot on a majority of devices but I don't get the point of having Initrd/Initramfs.As far as I've understood Initrd/Initramfs job is to temporary provide the file system drivers to actually load the root file system.
If this the case, then why don't we simply add the necessary file system drivers into the kernel itself.We have to ultimately load both the kernel and the Initrd/Initramfs so why no integrate both into one image file since both of them take the same amount of memory.
*******Update******
1. What actually constitutes the linux kernel? Is it just the vmlinuz image(approximately 5-6MB) or the collection of loadable modules,vmlinuz image, initrd file and other components.
2. Why is the size of the kernel image vmlinuz(approx 5-6MB) less than size of initrd file(approx 18MB). The kernel contains the code for many other things as compared to initrd that just contains code to mount the File system.
|
First, it's not just the filesystem drivers. It's also the drivers for whatever storage device the filesystem is on. And possibly more if you use LVM, encryption, etc.
Regardless, it's definitely possible to build them into the kernel. I know slackware at least has a kernel choice named 'huge' which does just that and does not require an initramfs for typical PC hardware.
The downside is that such a kernel has to include everything anyone might possibly need: every possible filesystem that might be used as root, the device drivers for whatever might hold that filesystem, etc. So you end up with a bloated kernel which contains a lot of unused code and wastes memory.
I think there are also some drivers which can only be built as kernel modules but that's more a design choice than a real technical limitation.
Answer to edits:
It probably depends who you ask and in what context. To me, it's everything which runs in kernel space so that includes all the drivers. A kernel developer might have a different view with many more names for different pieces.
Actually, the vast majority of the kernel code is loadable modules and drivers. Some of those are quite large. On my system, btrfs alone is 500 kB compressed. NFS is nearly as large. ext4 is 300 kB. There is a huge number of supported storage devices as well and you might need any of them to get your root filesystem. Just browse through /lib/modules/*/kernel/drivers/ on a linux system and you'll see.
| Why don't we include File System drivers in the kernel itself instead of using Initrd/Initramfs |
1,413,894,503,000 |
I've created a gentoo-live system which should be booted from a CF-card. The whole file-system is in a squashfs. I've created a custom initrd which first mounts the CF-card and from there the squashed filesystem into what will become /.
I'd like /etc to be writable so I've copied it to the CF-card added a bind. This however does not seem to work. The system boots but /etc is not mounted.
I'd like to know if my approach is right and what I can do to fix it or if not what would be the right way to achieve this.
Here's the init-script from my initrd:
#!/bin/busybox sh
mount -t proc none /proc
mount -t sysfs none /sys
mount /dev/sda1 /mnt/flash
mount -o loop /mnt/flash/filesystem.squashfs /mnt/root
mount -B /mnt/flash/etc /mnt/root/etc
mount -o remount,rw /mnt/root/etc
umount /proc
umount /sys
exec switch_root /mnt/root /sbin/init
This is the shortened output of cat /proc/mounts:
rootfs / rootfs rw 0 0
/dev/sda1 /mnt/flash ext2 rw,relatime,errors=continue,user_xattr,acl 0 0
/dev/loop0 / squashfs ro,relatime 0 0
...
|
BusyBox's built-in mount command doesn't recognize -B; you'll have to use -o bind:
mount -o bind /mnt/flash/etc /mnt/root/etc
Also, I think the remounting is unnecessary if /mnt/flash is already writable. But try fixing the bind mounting first.
| Mount /etc from disc into squashfs |
1,413,894,503,000 |
I just installed Debian 6.0, encrypted / and now I'm trying to boot. When GRUB comes up, I select Debian, it loads the initrd and asks for the root password, however I can't enter anything, because the system doesn't recognize my keyboard. It is a standard USB keyboard. What can I do to get my keyboard working?
|
Either add the following into the /etc/initramfs-tools/modules:
usbcore
uhci_hcd
ehci_hcd
usbhid
or change the module policy to most in /etc/initramfs-tools/initramfs.conf:
MODULES=most
After this, repack the initramfs with the command:
update-initramfs -u
| Getting keyboard to work in debian 6.0 in order to unlock root partition |
1,537,537,682,000 |
Background
I have a system that runs Linux. It's a NAS, and does not have any monitor, keyboard, or serial port. It does have a network port. I'm not happy with the software running on it, and am trying to get a different distro to run.
What I have
On the existing system, I can manage to get a new kernel and initrd booted, by using the web interface to upgrade the ROM, but that upgrade is a specially crafted image, that does nothing more than unpack a kernel, initrd, kexec, and runs kexec with the required arguments to boot the new kernel.
The initrd sets up a network connection, starts an SSH server (dropbear), and waits for it to end. It then runs a different script. Using this, I can do some testing: I can boot into that kernel/initrd, log in via SSH, customise the stage-2 script, kill dropbear, and hope for the best.
Using this approach, I have managed to install a functional OS on the hard disk. (For now, it's NixOS, if it matters, but I may change that in the future. My question isn't about any specific distro though.) I have intentionally not made it bootable. I wish to keep the flash memory as it is, so that aside from the data on the hard disk, the NAS remains "official". I have, however, obtained the distro's own kernel and initrd, that I would want to put in an upgrade image.
The problem
Using that kernel and initrd, the system does not start.
My attempts
I have put together a shared initrd, containing the distro's setup as well as my own, which continues to boot into dropbear. In an SSH shell, I then attempt to run the distro's init scripts. This fails, however, because it relies on being run as PID 1.
I then attempted to make PID 1 take arbitrary commands: I made it run scripts from a pipe, and wrote to that pipe from my remote shell, intending to inspect manually whether the command had the desired effect. However, that doesn't work: the init-shell (PID 1) sees EOF after the very first command, and immediately exits. Hello kernel panic.
I also attempted to test what would happen if I made it not care whether it was being run as PID 1, by passing systemd's --system option, and then run the distro's init script from my shell. In that form, I was unable to reproduce the problem: it just worked.
My question: What now?
At this point I'm looking back at the pipe approach for an alternative, something that actually works to run more than one command. Preferably something that also lets me see the commands' output.
Basically: I want to know how I can remotely see the output of the boot programs that run from PID 1, that cannot run in an SSH session, without actually attaching a monitor or serial cable.
Answers that take a completely different approach are also welcome, but please keep in mind the system restrictions I'm dealing with. I don't just not have a monitor or serial cable, I don't even have a VGA or serial port. I have one USB port that I could plug a keyboard into, if needed, but I am of course not able to see anything I type.
|
After starting an SSH session, other sessions can write there too, by writing to /dev/pts/<N>. So to see what is happening, since I'm already able to control what PID 1 will end up running, I just need to make it write there. Using exec 0<>/dev/pts/0 1<>/dev/pts/0 2<>/dev/pts/0 from PID 1 and making sure nothing else is reading/writing there I can see what's happening. When it eventually fails, the distro's init script prompts to ask what to do, and even properly responds to me entering R to reboot.
The actual problem I was having seems to be caused by required kernel modules not getting loaded. Although I was able to get everything working manually, which obviously means the block, RAID and filesystem modules were available and getting loaded, the distro's initscript relies on udev, and it turns out that requires a few additional modules, in particular unix (which I'd never have chosen myself to not build into the kernel).
| How can I remotely debug a broken initrd? |
1,537,537,682,000 |
I would like to boot a SLES and run it out of a ramdisk.
I would like to setup machines so that they start PXE boot and as part of the PXE boot process they pull across an image that is the root filesystem and then boot this.
Has anyone done this or similar yet?
My thinking is that the initrd is almost what i want to have although far too small and short on features. So i did a minimal install and then did a cpio of this to create my own custom initd. (This is about 350M, which although big is fine for this purpose).
It has trouble booting up at the point when it tries to fsck the /dev/shm/root. What is the correct way to stop this happening (I tried by setting in /etc/fstab, but no good).
As next option I set a sysconfig file to force READONLYROOT and this got me booting the init process as far as the point where it switches to /etc/init.d/rc3.d but now I can't get it to go further.
Any advice or ideas or if someone else has done this they that would all be great.
PS. Setup is big nodes with 1TB RAM and I don't want to have local filesystem for OS and the alternative is to have NFS server the root filesystem, but I don't want the NFS traffic so RAM disk seems like good option.
|
I have made good progress.
I edited the file /etc/init.d/boot.d/boot.rootfsck to add ramfs as a filesystem type exception to the fsck process. (line 79).
aufs|tmpfs|afs|cifs|nfs|novell|smb|ramfs|UNKNOWN*) MAY_FSCK=0 ;;
After doing this it is no longer necessary to have sysconfig with READONLYROOT.
After doing this i setup pxelinux.cfg to have a boot line as follows:
LABEL SLES11 InMemory OS
KERNEL suseBig/vmlinuz-3.0.74-0.6.8-default
APPEND initrd=suseBig/suseImage rdinit=/sbin/init
TIMEOUT 100
The file suseImage is a cpio archive of the whole root filesystem of a working install of SLES, but with a modified /etc/fstab line for root. (i had to build the CPIO archive by accessing this working SLES environment from another working OS (on another disk))
rootfs / rootfs defaults 0 0
Once this is all in place the node boots up happily and i now have a working ramdisk version of SLES that boots across the network via PXE. (so it is slow to boot, but after that it has no network traffic for OS). It has no persistence, but i solve that for my case in the application layer.
| initrd or ramfs for SLES as / |
1,537,537,682,000 |
I'm using Kubuntu 11.10 and before I upgrade to 12.04, I want to make snapshots of my filesystems. Coming to think of that, I realized that it can be very useful to create snapshots of logical volumes during boot before they are mounted. At that moment, the volume/filesystem should be clean and is perfect to be used for an image backup.
How can I create LV snapshots of my filesystems during boot, before the filesystems are being mounted by the kernel? I think this should be done in initrd, but unsure how.
|
Part of the purpose of LVM snapshots is that you can create them on the fly; there is no need to do it at boot time. LVM takes care to make sure the filesystem is in a consistent state when it creates the snapshot. One of, if not the most common use of LVM snapshots is to get a stable fs image you can make a backup of without having to shutdown the server.
| Create Logical Volume Snapshot at boot and before mount |
1,537,537,682,000 |
for now /boot on our linux machines is
/dev/sda1 497M 157M 340M 32% /boot
we want to create a new linux redhat template
and I have the feeling that /boot size is too small
for example as I know kdump use /boot and need space under /boot for this
so is it right to increase the /boot to 1G ?
|
For RHEL 7, Red Hat recommends that the /boot partition be set to at least 1 GiB in size. This is documented in the Installation Guide, Section 8.14.4.4: Recommended Partitioning Scheme
Quote:
/boot partition - recommended size at least 1 GiB
The partition mounted on /boot contains the operating system kernel,
which allows your system to boot Red Hat Enterprise Linux, along with
files used during the bootstrap process. Due to the limitations of
most firmwares, creating a small partition to hold these is
recommended. In most scenarios, a 1 GiB boot partition is adequate.
Unlike other mount points, using an LVM volume for /boot is not
possible - /boot must be located on a separate disk partition.
| how to know the right size of /boot |
1,537,537,682,000 |
I have an old laptop that has a built-in SD card reader, only it's not available at boot.
I can however grub boot linux (Debian) from a small 8GB USB key (USB 2.0), but it's very slow. The SD card is a lot faster and must be on a different interface.
I can't access the SD card from grub, but was wondering if I could load the Debian kernel and/or vmlinuz from the USB key and then continue booting from the SD card once the drivers for the SD card have been loaded in the kernel or initramfs?
I'm hesitant to mess with the grub config file since it clearly says do not edit, but it seems like you can specify different disks for the kernel/vmlinuz and initramfs; I'm just not sure how to do it and if loading either of those off the USB key will bring the SD card up?
Here's the relevant code from /boot/grub.cfg on the USB stick:
For booting into the USB stick:
### BEGIN /etc/grub.d/10_linux ###
function gfxmode {
set gfxpayload="${1}"
}
set linux_gfx_mode=
export linux_gfx_mode
menuentry 'Debian GNU/Linux' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-aaaa-aaaa-a’ {
load_video
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod ext2
set root='hd2,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd2,msdos1 --hint-efi=hd2,msdos1 --hint-baremetal=ahci2,msdos1 aaaa-aaaa-a
else
search --no-floppy --fs-uuid --set=root aaaa-aaaa-a
fi
echo 'Loading Linux 4.19.0-6-amd64 ...'
linux /boot/vmlinuz-4.19.0-6-amd64 root=UUID=aaaa-aaaa-a ro quiet
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-4.19.0-6-amd64
}
For booting into the SD/MMC card:
### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Debian GNU/Linux 10 (buster) (on /dev/mmcblk0p1)' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-XXXX-XXXX-X’ {
insmod part_msdos
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root XXXX-XXXX-X
else
search --no-floppy --fs-uuid --set=root XXXX-XXXX-X
fi
linux /vmlinuz root=/dev/mmcblk0p1
initrd /initrd.img
}
Thinking there must be a way to combine them?
I got it to boot off the SD card.
I had set up the SD card with LVM partitioning so had to install lvm2 onto the USB key since it was only setup as basic MBR partitioning.
I added:
insmod lvm
insmod ext2
to:
### BEGIN /etc/grub.d/05_debian_theme ###
and:
root=/dev/mapper/debian--vg-root
to the appropriate menuentry.
However, since the initramfs files are different on the USB and SD not everything loads properly at boot on the SD.
The USB install is a very minimal shell only boot whereas the SD is a full install with a desktop manager etc.
What I would like to do is have both separate and still be able to boot both with their respective initramfs files. I can do this for the USB card, and have a separate entry for the SD card to boot but it's using the minimal USB initramfs file.
The SD card considers /dev/mmcblk0p1 as its boot partition.
This results in two more questions:
How can I tell grub config where the boot folder is for the SD card? Is it possible to specify it in grub.cfg? I've copied all the files from the /dev/mmcblk0p1 partition to /boot/bootsd on the USB key.
How can I set the USB folder /boot/bootsd as /boot for the SD card? Use fstab and a symbolic link?
EDIT 3:
I think I have it figured out -- I simply changed:
initrd /initrd.img
to:
initrd /bootsd/initrd.img
Then I created an fstab entry on the SD card for the USB sdc1 using the UUID. Then created an ln alias from the /media/usbboot/boot/bootsd to /boot on the SD system.
I haven't configured non-free wifi yet so haven't done an apt-get update but assuming it will work.
|
GRUB uses the system firmware routines (i.e. BIOS in your case) for all of its disk I/O operations, so if BIOS cannot read the SD card, GRUB won't be able to do it either.
GRUB's job is to load the Linux kernel and initramfs files to RAM, and then transfer control to the Linux kernel. At that point, GRUB's job is done and it won't be involved in any further actions. Everything after that point is done by the Linux kernel and whatever drivers and tools are included in the initramfs file.
So, if your initramfs on the USB stick includes the driver for the SD card, all you need to do is to edit the root= boot parameter on this line:
linux /boot/vmlinuz-4.19.0-6-amd64 root=UUID=aaaa-aaaa-a ro quiet
to this:
linux /boot/vmlinuz-4.19.0-6-amd64 root=/dev/mmcblk0p1 ro quiet
But this is only the first step.
In order to allow your system to also update your kernel and/or bootloader when needed, you should then arrange for the /boot directory of the USB stick to get automatically mounted as /boot on your mostly-SD-card-based system. Since there is already a /boot directory on the USB stick, you may have to configure /etc/fstab to mount the USB stick to some other location, and make /boot a symbolic link pointing to /wherever_the_USB_is_mounted/boot.
Then run grub-mkconfig -o /tmp/test-grub.cfg to autogenerate a dummy test grub.cfg file in /tmp/, compare it to the active one on the USB stick and verify that the result makes sense in terms of the USB stick. To test, you can move the grub.cfg file on the USB stick aside and replace it with the generated one. If it works, your system should now be capable of kernel updates while using your "boot from USB, root filesystem on SD" scheme. This should be the maximally conservative (minimum-risk) way to make the necessary changes.
Alternatively, once you get the system booted using the SD as the root filesystem, you could just copy the kernel and initramfs files from the current /boot directory to the root directory of the USB stick, mount it as /boot, then reinstall GRUB on the USB stick using grub-install. It should auto-generate the various paths in the new grub.cfg file (now in the root directory of the USB stick's filesystem) to match the new situation. You may also want to use update-initramfs -u to update your initramfs file, to ensure it matches the new configuration. After testing, you can then delete /boot/boot and other remaining sub-directories of the USB-based installation. This method results a bit cleaner configuration than the maximally conservative way, but runs the risk of boot failure if the reinstallation of GRUB to the USB is unsuccessful.
Regarding your EDIT 2:
How can I tell grub config where the boot folder is for the SD card? Is it possible to specify it in grub.cfg? I've copied all the files from the /dev/mmcblk0p1 partition to /boot/bootsd on the USB key.
The grub-mkconfig simply expects to find the directory that contains the kernel and initramfs files at /boot. Your job is to arrange things to make the correct filesystem/directory be there. If you do this, any kernel and initramfs updates should get handled correctly automatically.
An alternative solution would be to write your own boot entry in /etc/grub.d/40_custom. Then you could use any pathnames you want - but you would also have to deal with updating them yourself, since a standard kernel package will simply install the vmlinuz-<version> file to /boot, create a companion initramfs file for it in the same directory, and run grub-mkconfig to refresh the configuration file in a standard location.
How can I set the USB folder /boot/bootsd as /boot for the SD card? Use fstab and a symbolic link?
Exactly. Having the extra bootsd folder there complicates things somewhat, but it should be doable. A fstab entry might be something like this:
UUID=aaaa-aaaa-a /usbkey <filesystem type> defaults 0 2
This would place the non-symlink path to the folder at /usbkey/boot/bootsd.
Then you can move the current /boot directory on the SD's filesystem aside and replace it with a symbolic link:
mv /boot /boot.old
ln -s /usbkey/boot/bootsd /boot
Remember that when GRUB talks about root filesystem for GRUB's own purposes (set root=<something> or search ... --set=root ...), it only means the root directory of whatever filesystem GRUB is about to load files from. At boot time, GRUB does not see a single unified directory tree of Linux: it basically only looks at one filesystem at a time.
For GRUB, the root= option on the linux <somewhere>/vmlinuz-<version> root=... line is just one more boot option for the Linux kernel - but for the kernel and/or the start-up scripts in the initramfs file, this option specifies which filesystem is used as the root filesystem by Linux.
| Grub: boot with USB key, then continue booting from SD card? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.