2022-06-14 15:40:29 +00:00
|
|
|
#!/bin/bash
|
|
|
|
ip4_addr=$1
|
|
|
|
ip6_addr=$2
|
2022-10-10 08:52:30 +00:00
|
|
|
ip6_addr_gw=$3
|
|
|
|
os=$4
|
2022-06-14 15:40:29 +00:00
|
|
|
|
|
|
|
sysctl -w net.ipv6.conf.all.disable_ipv6=0
|
|
|
|
sysctl -w net.ipv6.conf.eth1.accept_dad=0
|
2022-08-15 22:00:22 +00:00
|
|
|
sysctl -w net.ipv6.conf.eth1.accept_ra=0
|
|
|
|
sysctl -w net.ipv6.conf.eth1.forwarding=0
|
2022-06-14 15:40:29 +00:00
|
|
|
|
|
|
|
if [ -z "${os##*ubuntu*}" ]; then
|
|
|
|
netplan set ethernets.eth1.accept-ra=false
|
|
|
|
netplan set ethernets.eth1.addresses=["$ip4_addr"/24,"$ip6_addr"/64]
|
2022-10-18 11:14:10 +00:00
|
|
|
netplan set ethernets.eth1.gateway6="$ip6_addr_gw"
|
2022-06-14 15:40:29 +00:00
|
|
|
netplan apply
|
2022-08-15 22:00:22 +00:00
|
|
|
elif [ -z "${os##*alpine*}" ]; then
|
|
|
|
iplink set eth1 down
|
|
|
|
iplink set eth1 up
|
|
|
|
ip -6 addr add "$ip6_addr"/64 dev eth1
|
2022-10-18 11:14:10 +00:00
|
|
|
ip -6 r add default via "$ip6_addr_gw"
|
2022-06-14 15:40:29 +00:00
|
|
|
else
|
|
|
|
ip -6 addr add "$ip6_addr"/64 dev eth1
|
2022-10-18 11:14:10 +00:00
|
|
|
ip -6 r add default via "$ip6_addr_gw"
|
2022-06-14 15:40:29 +00:00
|
|
|
fi
|
2022-10-10 08:52:30 +00:00
|
|
|
ip addr show dev eth1
|
2022-10-18 11:14:10 +00:00
|
|
|
ip -6 r
|