Created
August 4, 2013 23:11
-
-
Save WebReflection/6152439 to your computer and use it in GitHub Desktop.
Quick walk through static ip in Arch Linux
This file contains hidden or 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
| systemctl disable dhcpcd@eth0.service | |
| # vi /etc/systemd/system/network.service | |
| # IP=192.168.1.2/24 | |
| # RT=192.168.1.254 | |
| [Unit] | |
| Description=Static Connectivity | |
| Wants=network.target | |
| Before=network.target | |
| BindsTo=sys-subsystem-net-devices-eth0.device | |
| After=sys-subsystem-net-devices-eth0.device | |
| [Service] | |
| Type=oneshot | |
| RemainAfterExit=yes | |
| ExecStart=/usr/bin/ip link set dev eth0 up | |
| ExecStart=/usr/bin/ip addr add 192.168.1.2/24 dev eth0 | |
| ExecStart=/usr/bin/ip route add default via 192.168.1.254 | |
| iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080 | |
| ExecStop=/usr/bin/ip addr flush dev eth0 | |
| ExecStop=/usr/bin/ip link set dev eth0 down | |
| [Install] | |
| WantedBy=multi-user.target | |
| # save then ... | |
| systemctl enable network | |
| systemctl start network | |
| # to have back the dhcp | |
| systemctl stop network | |
| dhcpcd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment