0

I have a kvm server where the guest vm's get internet acces due to a bridge. I would like to access the host from a guest vm by ssh but get a "port 22: Connection refused", altough i can ping the host on all ip's.

brctl show
bridge name     bridge id               STP enabled     interfaces
virbr0          8000.52540097d680       yes             virbr0-nic
                                                        vnet0
                                                        vnet1
                                                        vnet2

All traffic for the bridge is been forwarded with POSTROUTING in uptables on the host.

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination
RETURN     all  --  192.168.122.0/24     base-address.mcast.net/24
RETURN     all  --  192.168.122.0/24     255.255.255.255
MASQUERADE  tcp  --  192.168.122.0/24    !192.168.122.0/24     masq ports: 1024-65535
MASQUERADE  udp  --  192.168.122.0/24    !192.168.122.0/24     masq ports: 1024-65535
MASQUERADE  all  --  192.168.122.0/24    !192.168.122.0/24

How can i set up a ssh connection from the guest to the host?

Edit:

Chain INPUT (policy DROP)
ACCEPT     all  --  192.168.122.0/24     0.0.0.0/0
ACCEPT     all  --  192.168.122.0/24     0.0.0.0/0

Should accept all

Edit2:

iptables -L -n
Chain INPUT (policy DROP)
target     prot opt source               destination
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0
Badflags   tcp  --  0.0.0.0/0            0.0.0.0/0            tcp flags:0x11/0x01
Badflags   tcp  --  0.0.0.0/0            0.0.0.0/0            tcp flags:0x18/0x08
Badflags   tcp  --  0.0.0.0/0            0.0.0.0/0            tcp flags:0x30/0x20
Badflags   tcp  --  0.0.0.0/0            0.0.0.0/0            tcp flags:0x05/0x05
Badflags   tcp  --  0.0.0.0/0            0.0.0.0/0            tcp flags:0x03/0x03
Badflags   tcp  --  0.0.0.0/0            0.0.0.0/0            tcp flags:0x06/0x06
Badflags   tcp  --  0.0.0.0/0            0.0.0.0/0            tcp flags:0x3F/0x3F
Badflags   tcp  --  0.0.0.0/0            0.0.0.0/0            tcp flags:0x3F/0x00
Badflags   tcp  --  0.0.0.0/0            0.0.0.0/0            tcp flags:0x3F/0x29
Badflags   tcp  --  0.0.0.0/0            0.0.0.0/0            tcp flags:0x3F/0x2B
Badflags   tcp  --  0.0.0.0/0            0.0.0.0/0            tcp flags:0x3F/0x37
ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0            icmptype 0
ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0            icmptype 3
ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0            icmptype 11
ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0            icmptype 8
ACCEPT     all  --  192.168.122.0/24     0.0.0.0/0
Firewall   icmp --  0.0.0.0/0            0.0.0.0/0
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:80
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:443
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            state RELATED,ESTABLISHED
DROP       udp  --  0.0.0.0/0            0.0.0.0/0            udp spt:137 dpt:137
Rejectwall  all  --  0.0.0.0/0            0.0.0.0/0

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
DROP       all  --  0.0.0.0/0            0.0.0.0/0            state INVALID,NEW

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain Badflags (11 references)
target     prot opt source               destination
LOG        all  --  0.0.0.0/0            0.0.0.0/0            limit: avg 10/min burst 5 LOG flags 0 level 4 prefix "Badflags: "
DROP       all  --  0.0.0.0/0            0.0.0.0/0

Chain Firewall (1 references)
target     prot opt source               destination
DROP       all  --  0.0.0.0/0            0.0.0.0/0

Chain Rejectwall (1 references)
target     prot opt source               destination
REJECT     all  --  0.0.0.0/0            0.0.0.0/0            reject-with icmp-port-unreachable
spdfrx
  • 1
  • 2
  • Check the INPUT chain of the iptables on your kvm server. – yty Sep 27 '18 at 13:03
  • Update in op. Does that show enough? – spdfrx Sep 27 '18 at 13:58
  • Exactly what command did you run when you attempted to ssh? – Michael Hampton Sep 27 '18 at 19:20
  • When iptables is running and i try to connect to host: "port 22: Connection refused" When i disable iptables, i do get acces to host but guests lose internet connection. – spdfrx Oct 01 '18 at 08:38
  • Please show the verbose listing of the INPUT chain. Maybe the ACCEPT rules are on a different interface than you expected? – yty Oct 02 '18 at 08:37
  • Full output of iptables -L -n in op. Any recommendations? – spdfrx Oct 02 '18 at 11:50
  • You need the -v flag to show the interfaces these rules are attached to. Anyway, assuming that those "ACCEPT all" rules are on the correct interface, and/or you are ssh from the correct subnet, then I don't see why you can't ssh to your host. – yty Oct 08 '18 at 02:06

0 Answers0