Created
July 9, 2013 17:00
-
-
Save mcgrew/5959115 to your computer and use it in GitHub Desktop.
Systemd service to enable NAT routing.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wan_interface=ens32 | |
lan_interface=ens33 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Routing | |
Wants=network.target | |
Before=network.target | |
[Service] | |
Type=oneshot | |
RemainAfterExit=yes | |
EnvironmentFile=/etc/conf.d/routing | |
ExecStart=/usr/bin/iptables --table nat --append POSTROUTING --out-interface ${wan_interface} -j MASQUERADE | |
ExecStart=/usr/bin/iptables --append FORWARD --in-interface ${lan_interface} -j ACCEPT | |
ExecStart=/usr/bin/echo 1 > /proc/sys/net/ipv4/ip_forward | |
ExecStop=/usr/bin/iptables --flush | |
ExecStop=/usr/bin/iptables --table nat --flush | |
ExecStop=/usr/bin/iptables --delete-chain | |
ExecStop=/usr/bin/iptables --table nat --delete-chain | |
ExecStop=/usr/bin/echo 0 > /proc/sys/net/ipv4/ip_forward | |
[Install] | |
WantedBy=multi-user.target |
@mcgrew @enricostano, do you think below configuration can replace the systemd service described above?
#wan
[Match]
Name=ens32
[Network]
DHCP=ipv4
IPMasquerade=yes
#lan
[Match]
Name=ens33
[Network]
Address=0.0.0.0/28
DHCPServer=yes
IPForward=yes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is this still the way to go or maybe we can manage the IP forwarding differently since http://cgit.freedesktop.org/systemd/systemd/commit/?id=5a8bcb674f71a20e95df55319b34c556638378ce ? Thanks!