Gregg's MOTD

Tips & Tricks that I've Encountered Over the Years...

KVM: Configure libvirt Network

September 24, 2023 — Gregg Szumowski

You can update the network configuration for your KVM installation using the command line using the virsh command.

To list all of the available network enter the following command. The --all will is used to include the inactive networks:

# virsh net-list --all
Name State Autostart
-----------------------------------------
default active yes
NattedNetwork active yes

Then, edit the network you wish to update:

# EDITOR="vi" virsh net-edit NattedNetwork

Add host configuration(s) or whatever changes you wish to make to XML file:

<network>
<name>NattedNetwork</name>
<uuid>8483028d-667b-47e7-9a8e-f269783a8246</uuid>
<forward mode='nat'/>
<bridge name='virbr0' stp='on' delay='0'/>
<mac address='52:54:00:ad:b9:ed'/>
<ip address='192.168.122.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.122.2' end='192.168.122.254'/>
</dhcp>
</ip>
</network>

Once you’re done, restart the network for the changes to take effect:

# virsh net-destroy NattedNetwork
# virsh net-start NattedNetwork

Tags: cli, libvirt, kvm, network, motd

Find Your External IP Address

September 13, 2023 — Gregg Szumowski

It’s easy to find your internal IP address my using tools like ifconfig or ip a but to find your external IP address (the one that connects you to the outside world) you must use other means. Here are 3 simple commands that you can use to do just that:

$ curl ifcfg.me
72.76.yyy.xxx

$ curl icanhazip.com
72.76.yyy.xxx

$ nslookup myip.opendns.com. resolver1.opendns.com
Server: resolver1.opendns.com
Address: 208.67.222.222#53

Non-authoritative answer:
Name: myip.opendns.com
Address: 72.76.yyy.xxx

Tags: cli, network, curl, nslookup, motd