Using Variables with SED

All
I am trying to produce the following in /etc/ssh/sshd_config,

# IPv4 only
#ListenAddress 0.0.0.0
# IPv4 & IPv6
ListenAddress ::

to

# IPv4 only
ListenAddress <user-entry>
ListenAddress <user-entry>
# IPv4 & IPv6
#ListenAddress ::

The number of user entries can vary.

I can swap the #s ok

# IPv4 only
ListenAddress 0.0.0.0
# IPv4 & IPv6
#ListenAddress ::

The first entry I can manage eg 1.1.1.1 to give

# IPv4 only
ListenAddress 1.1.1.1
# IPv4 & IPv6
#ListenAddress ::

Now my problem - I would like to take the next user input eg 2.2.2.2 and insert it after the first Listen Address. Produces this,

# IPv4 only
ListenAddress 1.1.1.1
ListenAdresss 2.2.2.2
# IPv4 & IPv6
#ListenAddress ::

Can any one help me please....

Many Thanks

Try this:

awk 'NF && p && !/ListenAddress/{print v;p=0} /# IPv4 +only/{p=1}1' v="ListenAddress 1.1.1.2" infile