- Overview
- Configuration
- DEVICE
- IPADDR
- NETMASK
- PREFIX
- GATEWAY
- UUID
- HWADDR
- DEFROUTE
- PEERDNS
- IPV6_PEERDNS
- Change the IP Address
- Configure a Network Interface after Cloning a VM Image
- Change the UUID
- Where do I find the UUID of a network connection on Ubuntu Server? (no Network-Manager)
- 3 Answers 3
- What is the purpose of UUIDs for NICs?
- 2 Answers 2
- What is a UUID? How to generate and Set UUID for NICs and Bonds on RHEL/CentOS
Overview
The configuration files corresponding to the network interfaces are located in /etc/sysconfig/network-scripts.
DEVICE=eth0 NAME=eth0 UUID=539b9873-04b8-44cc-aa01-6e9911eaa244 #HWADDR=52:54:00:70:a5:21 TYPE=Ethernet ONBOOT=yes BOOTPROTO=none IPADDR=192.168.1.9 NETMASK=255.255.255.0 PREFIX=24 GATEWAY=192.168.1.1 DNS1=8.8.8.8 DEFROUTE=yes PEERDNS=no PEERROUTES=no IPV4_FAILURE_FATAL=yes IPV6INIT=no IPV6_AUTOCONF=no IPV6_DEFROUTE=no IPV6_FAILURE_FATAL=no IPV6_PEERDNS=no IPV6_PEERROUTES=no IPV6_PRIVACY=no PROXY_METHOD=none BROWSER_ONLY=no
Configuration
DEVICE
IPADDR
NETMASK
PREFIX
GATEWAY
UUID
A unique ID for the interface.
A unique value can be created with uuidgen
HWADDR
Specifying the hardware or MAC address using the HWADDR directive will influence the device naming procedure.
DEFROUTE
PEERDNS
The ifcfg parameter PEERDNS determines if the file /etc/resolv.conf is modified or not. If it is set to «yes», then the parameters DOMAIN, DNS1 and DNS2 will be used to set the search and nameserver entries in the file. If PEERDNS is set to «no», the file is not modified.
PEERDNS defaults to no unless DHCP is used, in which case it defaults to yes. If DHCP is used, usually we want to set PEERDNS to yes, unless more than one interfaces are configured, and other interface will configure DNS.
IPV6_PEERDNS
Change the IP Address
Modify/verify the following set of variables. Make sure the hardware address is correct.
DEVICE=eth0 HWADDR="08:00:27:0A:79:9F" IPADDR="172.20.1.3" PREFIX="16" NETMASK="255.255.0.0" GATEWAY="172.20.1.1"
Note that this is how a static address is changes even if NetworkManager is active.
Configure a Network Interface after Cloning a VM Image
In general, when cloning a system, you want to generated a different Mac address when cloning an image, to avoid collisions.
If «HWADDR» is set pointing to the old hardware address, we want to remove it from the cloned configuration file, because if it stays there, and the hardware address is not available, the interface won’t start.
Change the UUID
Use uuidgen and replace the value from the the ifcfg-* file.
Where do I find the UUID of a network connection on Ubuntu Server? (no Network-Manager)
I have a clean installation of Ubuntu 12.04 Server. I would like to find the UUID for a network connection. How do I find this? ifconfig -a does not list it:
eth0 Link encap:Ethernet HWaddr 00:1e:67:6a:78:a8 inet addr:192.168.50.18 Bcast:192.168.50.255 Mask:255.255.255.0 inet6 addr: fe80::21e:67ff:fe6a:78a8/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:572287 errors:0 dropped:0 overruns:0 frame:0 TX packets:70324 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:222908307 (222.9 MB) TX bytes:7982096 (7.9 MB) Interrupt:16 Memory:c2300000-c2320000
user@server# nmcli The program 'nmcli' is currently not installed. You can install it by typing: apt-get install network-manager
user@desktop# nmcli c list NAME UUID TYPE TIMESTAMP-REAL Wired connection 2 d00a6778-80d6-4812-ad54-041de24e47fe 802-3-ethernet Mon 16 Dec 2013 12:20:09 EST Wired connection 1 4fb95570-1922-495a-b498-846b7a6b0655 802-3-ethernet Tue 17 Dec 2013 11:20:03 EST miwifi f3182ff5-81c2-44c4-9c4b-d3a1f0a550e9 802-11-wireless never
How do I find it when network-manager isn’t installed? Surely I don’t have to install network-manager?
uuid for what? In linux, network connections don’t have uuid. Its possible dbus assigns a uuid to a network connection in ubuntu. Is this what you mean?
Apologies for the delay. I have added extra info from a desktop machine. It’s possible that the UUID is created by Network-Manager which would be frustrating. I also saw UUIDs being used for network connections in OpenStack Quantum and thought it might be lower-level, but perhaps they’re both implementing their own UUIDs for the connections.
3 Answers 3
The UUID is part of Network Manager. If you don’t have Network Manager installed and enabled, then you don’t have this UUID.
It is not related to OpenStack Quantum UUID at all.
Therefore, you cannot find the UUID. It does not exist.
The UUID is generated with a tool from the util-linux package: uuidgen, this generates random numbers. uuidgen is also used to generate UUID’s for partitions at their creation and invoked by tune2fs when you request it to create a new UUID for a partition.
Expect several tools to identify a device as new when you change the UUID in configuration files.
The UUID for network card is a runtime thing, done by NetworkManager. The closest you can get to find your network card in «/dev» is actually to look into «/proc» instead, where you can see there is no UUID mentioned anywhere:
[root@kubeadm-test ~]# ls -l /sys/class/net/ total 0 lrwxrwxrwx. 1 root root 0 Jan 22 08:35 enp1s0 -> ../../devices/pci0000:00/0000:00:02.0/0000:01:00.0/virtio0/net/enp1s0 lrwxrwxrwx. 1 root root 0 Jan 22 08:35 lo -> ../../devices/virtual/net/lo [root@kubeadm-test ~]# [root@kubeadm-test ~]# nmcli connection NAME UUID TYPE DEVICE enp1s0 7be41c51-becf-3963-bd4f-1562dd489fb3 ethernet enp1s0 [root@kubeadm-test ~]#
The «nmcli conn show enp1s0» command shows UUID and not the HW address.
[root@kubeadm-test ~]# nmcli conn show enp1s0 connection.id: enp1s0 connection.uuid: 7be41c51-becf-3963-bd4f-1562dd489fb3 connection.stable-id: -- connection.type: 802-3-ethernet connection.interface-name: enp1s0 connection.autoconnect: yes connection.autoconnect-priority: -999 connection.autoconnect-retries: -1 (default) connection.multi-connect: 0 (default) connection.auth-retries: -1 connection.timestamp: 1611301844 connection.read-only: no connection.permissions: -- connection.zone: -- connection.master: -- connection.slave-type: -- connection.autoconnect-slaves: -1 (default) connection.secondaries: -- connection.gateway-ping-timeout: 0 connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 802-3-ethernet.duplex: -- 802-3-ethernet.auto-negotiate: no 802-3-ethernet.mac-address: -- 802-3-ethernet.cloned-mac-address: -- 802-3-ethernet.generate-mac-address-mask:-- 802-3-ethernet.mac-address-blacklist: -- 802-3-ethernet.mtu: auto 802-3-ethernet.s390-subchannels: --
The «nmcli device show enp1s0» command shows HWADDR and not the UUID.
[root@kubeadm-test ~]# nmcli device show enp1s0 GENERAL.DEVICE: enp1s0 GENERAL.TYPE: ethernet GENERAL.HWADDR: 52:54:00:58:A4:20 GENERAL.MTU: 1500 GENERAL.STATE: 100 (connected) GENERAL.CONNECTION: enp1s0 GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/1 WIRED-PROPERTIES.CARRIER: on IP4.ADDRESS[1]: 192.168.122.217/24 IP4.GATEWAY: 192.168.122.1 IP4.ROUTE[1]: dst = 0.0.0.0/0, nh = 192.168.122.1, mt = 100 IP4.ROUTE[2]: dst = 192.168.122.0/24, nh = 0.0.0.0, mt = 100 IP4.DNS[1]: 192.168.122.1 IP6.ADDRESS[1]: fe80::5054:ff:fe58:a420/64 IP6.GATEWAY: -- IP6.ROUTE[1]: dst = fe80::/64, nh = . mt = 100 IP6.ROUTE[2]: dst = ff00::/8, nh = . mt = 256, table=255 [root@kubeadm-test ~]#
What is the purpose of UUIDs for NICs?
On Fedora/RHEL/CentOS there is a line in /etc/sysconfig/network-scripts/ifcfg-x files which defines UUID :
UUID=30fcd648-ad1e-4428-as6f-951e8e4d16df
NICs have MAC addresses by them selves, so what is the purpose of pointing UUIDs to NICs when there is already an identification number (MAC) and also unlike file systems UUIDs they can’t be stored on device itself?
Not all network interfaces are Ethernet. Serial interfaces and TUN interfaces (and probably many more) do not have MACs. Though, I’m not sure what RedHat uses those UUIDs for.
2 Answers 2
Ethernet cards might have (supposedly) unique MAC addresses, but what about virtual interfaces like aliases (e.g. eth0:0 ), bridges or VPNs? They need an ID too, so an UUID would be a good fit.
By the way, since the question is about NetworkManager and NetworkManager deals with connections, there are scenarios where you can have multiple connections for a device. For example you have a laptop with an Ethernet card which you use both at home and at work. At home you’re using only IPv4 like most home users, but at work you’re using only IPv6 because the company managed to migrate to it. So you have two different connections which need different IDs, so the MAC address of the Ethernet card can’t be used by itself. Therefore an UUID is again a good fit for an ID.
Virtual Adapters Have Virtual MAC too, seems that is used by network manager itself: centos.org/forums/viewtopic.php?t=8524
how is the uuid for the ethernet created? How is the UUID in the ifcfg-eth0 file for home and work related to the device itself?
@mcr, I don’t think it matters what kind the UUID is, as long as it’s an UUID. So you could use the command line program uuidgen (from util-linux) to generate one.
What is a UUID? How to generate and Set UUID for NICs and Bonds on RHEL/CentOS
When you work with the Network management tools like nmcli or nmtui they create it automatically and save it in the config file. While you create the configurations manually, you’ll need to generate the UUID for NICs or bonds. Let’s do that now.
1. For Example, Lets Generate UUID for em1 interface through uuidgen .
[root@DBBACKSERVER ~]# uuidgen em1
e9932709-4717-486f-a9a8-a8b8d89ed017
2. Now add the UUID value to to em1 Configuration File.
[root@DBBACKSERVER ~]#vi /etc/sysconfig/network-scripts/ifcfg-em1
UUID=e9932709-4717-486f-a9a8-a8b8d89ed017
3. Now save the Config File
4. Restart the Network Service to take that effect.
[root@DBBACKSERVER ~]#systemctl restart network
You can Generate UUID for Bond Network as well. Lets Do that:
[root@DBBACKSERVER ~]# uuidgen ifcfg-bond0
9e0ca102-1bf8-4789-bcf3-38e8bafaf1af
1. Now add the the UUID to Bond0 Config File.
[root@DBBACKSERVER ~]# vi /etc/sysconfig/network-scripts/ifcfg-bond0
2. Restart the Network Service to take that effect.
3. Now you can Check the UUID’s for this device is Properly Set or Not.
[root@DBBACKSERVER ~]# nmcli connection
NAME UUID TYPE DEVICE
bond0 9e0ca102-1bf8-4789-bcf3-38e8bafaf1af bond bond0
em1 e9932709-4717-486f-a9a8-a8b8d89ed017 802-3-ethernet em1
em2 b11498f4-cc61-4366-a7bd-cec968be9e42 802-3-ethernet em2
[root@DBBACKSERVER ~]#