Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
flame-clmc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
flame
flame-clmc
Commits
7aa44dd1
Commit
7aa44dd1
authored
6 years ago
by
MJB
Browse files
Options
Downloads
Patches
Plain Diff
persistent ip tables
parent
472d04ce
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Vagrantfile
+8
-0
8 additions, 0 deletions
Vagrantfile
Vagrantfile.libvirt
+8
-0
8 additions, 0 deletions
Vagrantfile.libvirt
scripts/test/fixture.sh
+24
-17
24 additions, 17 deletions
scripts/test/fixture.sh
with
40 additions
and
17 deletions
Vagrantfile
+
8
−
0
View file @
7aa44dd1
$lxc_script
=
<<-
SCRIPT
$lxc_script
=
<<-
SCRIPT
apt-get update
apt-get update
# install util for persistent ip tables
echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections
echo iptables-persistent iptables-persistent/autosave_v6 boolean true | sudo debconf-set-selections
sudo apt-get -y install iptables-persistent
# install lxc
apt-get install lxc lxc-templates wget bridge-utils jq -y
apt-get install lxc lxc-templates wget bridge-utils jq -y
lxc-checkconfig
lxc-checkconfig
# configure lxc for specific CIDR network
touch /etc/lxc/dnsmasq.conf
touch /etc/lxc/dnsmasq.conf
sed -i s/10.0.3/172.40.231/g /etc/default/lxc-net
sed -i s/10.0.3/172.40.231/g /etc/default/lxc-net
sed -i s/#LXC_DHCP_CONFILE/LXC_DHCP_CONFILE/g /etc/default/lxc-net
sed -i s/#LXC_DHCP_CONFILE/LXC_DHCP_CONFILE/g /etc/default/lxc-net
...
...
This diff is collapsed.
Click to expand it.
Vagrantfile.libvirt
+
8
−
0
View file @
7aa44dd1
$lxc_script = <<-SCRIPT
$lxc_script = <<-SCRIPT
apt-get update
apt-get update
# install util for persistent ip tables
echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections
echo iptables-persistent iptables-persistent/autosave_v6 boolean true | sudo debconf-set-selections
sudo apt-get -y install iptables-persistent
# install lxc
apt-get install lxc lxc-templates wget bridge-utils jq -y
apt-get install lxc lxc-templates wget bridge-utils jq -y
lxc-checkconfig
lxc-checkconfig
# configure lxc for specific CIDR network
touch /etc/lxc/dnsmasq.conf
touch /etc/lxc/dnsmasq.conf
sed -i s/10.0.3/172.40.231/g /etc/default/lxc-net
sed -i s/10.0.3/172.40.231/g /etc/default/lxc-net
sed -i s/#LXC_DHCP_CONFILE/LXC_DHCP_CONFILE/g /etc/default/lxc-net
sed -i s/#LXC_DHCP_CONFILE/LXC_DHCP_CONFILE/g /etc/default/lxc-net
...
...
This diff is collapsed.
Click to expand it.
scripts/test/fixture.sh
+
24
−
17
View file @
7aa44dd1
...
@@ -87,14 +87,16 @@ create() {
...
@@ -87,14 +87,16 @@ create() {
# set forward ports
# set forward ports
ports
=
$(
echo
$SERVICE
| jq
-r
'.forward_ports'
)
ports
=
$(
echo
$SERVICE
| jq
-r
'.forward_ports'
)
for
row
in
$(
echo
"
${
ports
}
"
| jq
-r
'.[] | @base64'
)
;
do
if
[
"
$ports
"
!=
"null"
]
;
then
_jq
()
{
for
row
in
$(
echo
"
${
ports
}
"
| jq
-r
'.[] | @base64'
)
;
do
echo
${
row
}
|
base64
--decode
| jq
-r
${
1
}
_jq
()
{
}
echo
${
row
}
|
base64
--decode
| jq
-r
${
1
}
guest_port
=
$(
_jq
'.guest'
)
}
host_port
=
$(
_jq
'.host'
)
guest_port
=
$(
_jq
'.guest'
)
iptables
-t
nat
-A
PREROUTING
-p
tcp
-i
enp0s3
--dport
${
host_port
}
-j
DNAT
--to-destination
${
ip
}
:
${
guest_port
}
host_port
=
$(
_jq
'.host'
)
done
iptables
-t
nat
-A
PREROUTING
-p
tcp
-i
enp0s3
--dport
${
host_port
}
-j
DNAT
--to-destination
${
ip
}
:
${
guest_port
}
done
fi
fi
fi
}
}
...
@@ -130,14 +132,17 @@ destroy() {
...
@@ -130,14 +132,17 @@ destroy() {
# remove forward ports
# remove forward ports
ports
=
$(
echo
$SERVICE
| jq
-r
'.forward_ports'
)
ports
=
$(
echo
$SERVICE
| jq
-r
'.forward_ports'
)
for
row
in
$(
echo
"
${
ports
}
"
| jq
-r
'.[] | @base64'
)
;
do
if
[
"
$ports
"
!=
"null"
]
;
then
_jq
()
{
echo
"destroy ports"
echo
${
row
}
|
base64
--decode
| jq
-r
${
1
}
for
row
in
$(
echo
"
${
ports
}
"
| jq
-r
'.[] | @base64'
)
;
do
}
_jq
()
{
guest_port
=
$(
_jq
'.guest'
)
echo
${
row
}
|
base64
--decode
| jq
-r
${
1
}
host_port
=
$(
_jq
'.host'
)
}
iptables
-t
nat
-D
PREROUTING
-p
tcp
-i
enp0s3
--dport
${
host_port
}
-j
DNAT
--to-destination
${
ip
}
:
${
guest_port
}
guest_port
=
$(
_jq
'.guest'
)
done
host_port
=
$(
_jq
'.host'
)
iptables
-t
nat
-D
PREROUTING
-p
tcp
-i
enp0s3
--dport
${
host_port
}
-j
DNAT
--to-destination
${
ip
}
:
${
guest_port
}
done
fi
fi
fi
}
}
...
@@ -200,6 +205,8 @@ for service_name in $service_names; do
...
@@ -200,6 +205,8 @@ for service_name in $service_names; do
fi
fi
done
done
echo
"------>Create iptables summary"
echo
"------>Create iptables summary"
iptables
-t
nat
-L
-n
-v
iptables
-t
nat
-L
-n
-v
iptables-save
iptables-save
>
/etc/iptables/rules.v4
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment