Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8967863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:20:25+00:00 2026-06-15T17:20:25+00:00

I installed kvm and set several guests on a server using vmbuilder. Here is

  • 0

I installed kvm and set several guests on a server using vmbuilder. Here is the following configuration :

server host1 (xxx.xxx.xxx.xxx) ->  guest vm1 (192.168.122.203)
                               ->  guest vm2 (192.168.122.204)

Where xxx.xxx.xxx.xxx is the fix IP address of host1.

I would like to connect to vm1 using the following command:

ssh username@host1 -p 2222

I tried to do it by adding the following rule in iptables:

sudo iptables --table nat --append PREROUTING --protocol tcp --destination xxx.xxx.xxx.xxx --destination-port 2222 --jump DNAT --to-destination 192.168.122.203:22

But I got a timeout when I’m running:

ssh username@host1 -p 2222

Here are my iptables rules:

sudo iptables -nL -v --line-numbers -t nat
Chain PREROUTING (policy ACCEPT 32446 packets, 3695K bytes)
num   pkts bytes target     prot opt in     out     source               destination         
1        7   420 DNAT       tcp  --  *      *       0.0.0.0/0            xxx.xxx.xxx.xxx        tcp dpt:2222 to:192.168.122.203:22

Chain INPUT (policy ACCEPT 8961 packets, 968K bytes)
num   pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 350 packets, 23485 bytes)
num   pkts bytes target     prot opt in     out     source               destination         

Chain POSTROUTING (policy ACCEPT 357 packets, 23905 bytes)
num   pkts bytes target     prot opt in     out     source               destination         
1      151  9060 MASQUERADE  tcp  --  *      *       192.168.122.0/24    !192.168.122.0/24     masq ports: 1024-65535
2       99  7524 MASQUERADE  udp  --  *      *       192.168.122.0/24    !192.168.122.0/24     masq ports: 1024-65535
3        3   252 MASQUERADE  all  --  *      *       192.168.122.0/24    !192.168.122.0/24



sudo iptables -nL -v --line-numbers 
Chain INPUT (policy ACCEPT 14 packets, 1147 bytes)
num   pkts bytes target     prot opt in     out     source               destination         
1      454 30229 ACCEPT     udp  --  virbr0 *       0.0.0.0/0            0.0.0.0/0            udp dpt:53
2        0     0 ACCEPT     tcp  --  virbr0 *       0.0.0.0/0            0.0.0.0/0            tcp dpt:53
3        0     0 ACCEPT     udp  --  virbr0 *       0.0.0.0/0            0.0.0.0/0            udp dpt:67
4        0     0 ACCEPT     tcp  --  virbr0 *       0.0.0.0/0            0.0.0.0/0            tcp dpt:67

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination         
1     589K 2304M ACCEPT     all  --  *      virbr0  0.0.0.0/0            192.168.122.0/24     state RELATED,ESTABLISHED
2     403K   24M ACCEPT     all  --  virbr0 *       192.168.122.0/24     0.0.0.0/0           
3        0     0 ACCEPT     all  --  virbr0 virbr0  0.0.0.0/0            0.0.0.0/0           
4        1    60 REJECT     all  --  *      virbr0  0.0.0.0/0            0.0.0.0/0            reject-with icmp-port-unreachable
5        0     0 REJECT     all  --  virbr0 *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-port-unreachable

Chain OUTPUT (policy ACCEPT 4 packets, 480 bytes)
num   pkts bytes target     prot opt in     out     source               destination

Any advices will be appreciate.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:20:26+00:00Added an answer on June 15, 2026 at 5:20 pm

    OK, I found the answer:

    I added those 2 rules to the nat table:

    $sudo iptables -t nat -A PREROUTING -p tcp --dport 2222 -j DNAT --to-destination 192.168.122.203:22
    $sudo iptables -t nat -A POSTROUTING -p tcp --dport 22 -d 192.168.122.203 -j SNAT --to 192.168.122.1
    

    Then I deleted the rule 4 et 5 of the chain FORWARD of the table filter

    $sudo iptables -nL -v --line-numbers -t filter
    
    Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
    (...)        
    4        7   420 REJECT     all  --  *      virbr0  0.0.0.0/0            0.0.0.0/0            reject-with icmp-port-unreachable
    5        0     0 REJECT     all  --  virbr0 *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-port-unreachable
    
    $sudo iptables -D FORWARD 5 -t filter
    $sudo iptables -D FORWARD 4 -t filter
    

    And now I connect to vm1 by doing:

    $ssh user1@host -p 2222
    user1@vm1:~$
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have installed KVM on my Ubuntu system. Using vmbuilder , I setup a
I installed a Windows Server 2003 virtual machine (KVM, VM specs 1x 3.8GHz and
Installed Mono 2.4 on Ubuntu using the instructions here: http://www.nabble.com/forum/PrintPost.jtp?post=22841086 When I run xsp
I installed clojure-mode and slime using the emacs starter kit and I get this
I'm building a piece of software that needs to spin up KVM guests dynamically
Installed SlikSvn on Window 2008 server Created Repository at c:\dia\svn\repos running this windows service
Installed PEAR and followed the directions on http://www.phpunit.de/manual/current/en/installation.html : pear config-set auto_discover 1 pear
I installed Tomcat using the Windows installer ages ago and it runs fine as
I have a server with KVM. Running Centos 5. Can you show me install
I installed the playframework fbconnect module (version 0.6). I keep getting the following error.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.