XCP-ng
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    XCP-ng firewall

    Scheduled Pinned Locked Moved Compute
    9 Posts 4 Posters 3.0k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B Offline
      Byte0
      last edited by

      I have a UPS connected to XCP-ng via USB. I have a backup server I need to setup to monitor the UPS for shutdown as a secondary NUT host.

      XCP-ng blocks NUT server communication. What would be the best way to edit iptables (or nftables, I forget which XCP-ng uses) to allow the NUT secondary server to communicate with the primary NUT service running on XCP-ng?

      BenjiReisB P 2 Replies Last reply Reply Quote 0
      • BenjiReisB Offline
        BenjiReis Vates 🪐 XCP-ng Team @Byte0
        last edited by

        @Byte0 Hi!

        /etc/xapi.d/plugins/firewall-port {open|close} port protocol should do the trick. Beware we advised against modifying this config for obvious security consideration.
        So know what you're doing 😉

        B 2 Replies Last reply Reply Quote 0
        • B Offline
          Byte0 @BenjiReis
          last edited by Byte0

          @BenjiReis am I crazy or does the firewall-port script have a bug? If I use the firewall-port script to open the port then use firewall-port check 3493 tcp as a way to check, it reports that it is not open. The code needs to be fixed from

              check)
                  if [[ -z `iptables -S $CHAIN | grep " $PORT "` ]]
                  then
                      echo "Port $PORT open: true"
                  else
                      echo "Port $PORT open: false"
                  fi
                  ;;
          

          to

              check)
                  if [[ -n `iptables -S $CHAIN | grep " $PORT "` ]]
                  then
                      echo "Port $PORT open: true"
                  else
                      echo "Port $PORT open: false"
                  fi
                  ;;
          

          or

              check)
                  if [[ -z `iptables -S $CHAIN | grep " $PORT "` ]]
                  then
                      echo "Port $PORT open: false"
                  else
                      echo "Port $PORT open: true"
                  fi
                  ;;
          

          If I knew how to do a git pull request and all that I'd do it, however I do not.

          1 Reply Last reply Reply Quote 0
          • B Offline
            Byte0 @BenjiReis
            last edited by

            @BenjiReis just checked the repo: https://github.com/xcp-ng/xcp-ng-xapi-plugins/tree/master/SOURCES/etc/xapi.d/plugins

            That doesn't even have the firewall-port script in it, so not sure what repository contains that to send a fix to.

            BenjiReisB 1 Reply Last reply Reply Quote 0
            • olivierlambertO Offline
              olivierlambert Vates 🪐 Co-Founder CEO
              last edited by

              Ping @stormi

              1 Reply Last reply Reply Quote 0
              • BenjiReisB Offline
                BenjiReis Vates 🪐 XCP-ng Team @Byte0
                last edited by

                @Byte0 Hi the script is not provided by this repo but directly by the xapi rpm:

                [10:47 r620-s2 ~]# rpm -qf /etc/xapi.d/plugins/firewall-port
                xapi-core-1.249.36-1.2.xcpng8.2.x86_64
                

                Anyway yes the check method is weird because it answer the opposite of the reality - but... it's by design according to upstream: https://github.com/xapi-project/xen-api/blob/45d934eec88def324799e0c428df14e726eb8566/ocaml/xapi/dbsync_slave.ml#L129-L134

                But the open/close method works as expected and then you can see the rules are correctly added to iptables.

                B 1 Reply Last reply Reply Quote 0
                • P Offline
                  ph7 @Byte0
                  last edited by ph7

                  @Byte0
                  Hi
                  There was a time this summer or spring when NUT-server was unavailable from the repo.
                  I decided to follow the "don't fiddle with dom0"
                  I let a mini server control the UPS and remotely activate a script on the host at power failure.
                  edit: changed USB > UPS

                  1 Reply Last reply Reply Quote 0
                  • B Offline
                    Byte0 @BenjiReis
                    last edited by Byte0

                    @BenjiReis The xapi is written in OCaml? That is pretty cool. I would love to learn OCaml one day.

                    Anyways, doesn't seem intuitive to design it this way:
                    334b8d7a-6f7e-4796-97c2-3c1fe4144fb6-Screenshot from 2024-10-22 08-02-03.png

                    Going to file an issue in that repo to see what happens. I suppose they would have to fix the OCaml code you linked as well.

                    B 1 Reply Last reply Reply Quote 1
                    • B Offline
                      Byte0 @Byte0
                      last edited by Byte0

                      This post is deleted!
                      1 Reply Last reply Reply Quote 0

                      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                      With your input, this post could be even better 💗

                      Register Login
                      • First post
                        Last post