You can use lsof
and watch
to do this, like so:
$ watch -n1 lsof -i TCP:80,443
Example output
dropbox 3280 saml 23u IPv4 56015285 0t0 TCP greeneggs.qmetricstech.local:56003->snt-re3-6c.sjc.dropbox.com:http (ESTABLISHED)
thunderbi 3306 saml 60u IPv4 56093767 0t0 TCP greeneggs.qmetricstech.local:34788->ord08s09-in-f20.1e100.net:https (ESTABLISHED)
mono 3322 saml 15u IPv4 56012349 0t0 TCP greeneggs.qmetricstech.local:54018->204-62-14-135.static.6sync.net:https (ESTABLISHED)
chrome 11068 saml 175u IPv4 56021419 0t0 TCP greeneggs.qmetricstech.local:42182->stackoverflow.com:http (ESTABLISHED)
Two things could be the cause of this:
One possible cause is the way you've built the private network (using the bridge on the host). It would be much safer and easier to configure this using virt-manager
. If your host is CLI only, install it on a remote desktop/laptop and connect over SSH to the host.
Once installed, connect to the hypervisor, right click on it's name in the list and choose 'Details'. On the 'Virtual Networks' tab you can add a new network by clicking on the '+' button (lower,left). The wizard will guide you through the process, but make sure you un-check the options for IPv4 and IPv6 addresses (you don't need them as it's a point-to-point link) and choose the radio button for 'Private network'. Continue with the wizard and exit.
If you're a die-hard command line only person, then the above can be carried out using the virsh net-define
command line interface. Create an XML file such as the example below (virbr2
is an unused bridge name - use brctl show
to list yours):
<network>
<name>private</name>
<bridge name="virbr2" />
</network>
Then import it with:
# virsh net-define <XML filename>
Once the above is done, you can edit each VM to use this new private network (you'll have to reboot the VMs for this to take effect). Once you've edited the VM configuration, you'll be ready to log in to each one and configure the OS with the relevant IP details (from your OP). But, read on first...
Secondly, you have no routes between the two VMs pointing to the new interfaces.
Another
This is because you've configured the IP address with a /32
prefix.
When editing the connection use the format a.b.c.d/p
to set the prefix; otherwise, without a prefix, it will default to /32
:
# nmcli con edit "Wired connection 1"
nmcli> set ipv4.addresses 10.1.1.1/30
nmcli> save
nmcli> quit
# systemctl restart network
Configuring the network manually also works:
NM_CONTROLLED=no
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
IPADDR=10.1.1.1
PREFIX=30
Carry out a similar procedure on the other VM (10.1.1.2/30
) and it should work.
Note: You could use /31
but only if you changed the IP addresses to 10.1.1.0
and 10.1.1.1
. This may cause problems as the first address in the range is usually reserved for the network address and the last for broadcast. As you only have two addresses with /31
, you'd have none left for the hosts. Best stick with /30
, which gives you 4 addresses - two reserved and two for your hosts.
Best Answer
Use
netstat
. For examplelists all UDP (
u
), TCP (t
) and RAW (w
) outgoing connections (not usingl
ora
) in a numeric form (n
, prevents possible long-running DNS queries) and includes the program (p
) associated with that.Consider adding the
c
option to get output being updated continuously.