ansible: gsm-tester: Enable ip forwarding and masquerading on boot

Some nodes in the internal network, such as LimeNetMicro, will need
Internet access to upgrade osmo-trx-lms from OBS repos.
It also makes it easier to update manually other nodes inside the
internal network.

Change-Id: I2c89cf9cfcb55b3153e7be212c68ffa8db0f6927
This commit is contained in:
Pau Espin 2019-11-26 14:07:01 +01:00 committed by pespin
parent 13eaaa3644
commit 2d8903c363
5 changed files with 34 additions and 2 deletions

View File

@ -4,4 +4,5 @@ The network configuration is not set by default.
# variables
- `bts_interface` (eth1): on which network interface the bts is configured.
- `bts_interface` (enp2s0): on which network interface the bts is configured.
- `gw_interface` (enp1s0): on which network interface the traffic is routed towards default gateway.

View File

@ -1,3 +1,4 @@
---
bts_interface: eth1
bts_interface: enp2s0
gw_interface: enp1s0

View File

@ -0,0 +1 @@
net.ipv4.ip_forward=1

View File

@ -9,3 +9,15 @@
- name: start all network interface
command: ifup -a
when: gsm_tester_network_interface is changed
- name: allow ip forwarding and masquerading traffic from internal network (iptables)
template:
src: etc/iptables-ogt
dest: /etc/network/if-up.d/iptables-ogt
mode: 0755
- name: allow ip forwarding from internal network (sysctl)
copy:
src: ogt-sysctl.conf
dest: /etc/sysctl.d
notify: restart udev

View File

@ -0,0 +1,17 @@
#!/bin/sh
IPT="/sbin/iptables"
if [ "$IFACE" = "{{ gw_interface }}" ]; then
# Apply masquerading if not yet applied:
if [ "x$($IPT -t nat -S | grep "\-A POSTROUTING -o {{ gw_interface }} -j MASQUERADE" -c)" = "x0" ]; then
$IPT -t nat -A POSTROUTING -o {{ gw_interface }} -j MASQUERADE
fi
# Allow IP forwarding if not yet enabled:
if [ "x$($IPT -t filter -S | grep "\-A FORWARD -j ACCEPT" -c)" = "x0" ]; then
$IPT -t filter -A FORWARD -j ACCEPT
fi
echo "osmo-gsm-tester iptables rules loaded."
fi