VPN 클라이언트(softEther)를 부팅하기 위해 SystemD OS 부팅을 사용하고 있지만 VPN 클라이언트 네트워크 인터페이스의 로컬 인터페이스에 고정 IP를 할당하는 데 문제가 있습니다.
이것은 내 SystemD 구성입니다.
[Unit]
Description=SoftEther VPN Client
After=network.target auditd.service
ConditionPathExists=!/usr/local/vpnclient/vpnclient/do_not_run
[Service]
Type=forking
EnvironmentFile=-/usr/local/vpnclient/vpnclient
ExecStart=/usr/local/vpnclient/vpnclient start
ExecStop=/usr/local/vpnclient/vpnclient stop
KillMode=process
Restart=on-failure
# Hardening
PrivateTmp=yes
ProtectHome=yes
ProtectSystem=full
ReadOnlyDirectories=/
ReadWriteDirectories=-/usr/local/vpnclient/vpnclient
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW CAP_SYS_NICE CAP_SYS_ADMIN CAP_SETUID
[Install]
WantedBy=multi-user.target
서비스를 시작하면 로컬 인터페이스가 나타나지만 구성한 고정 IP는 없습니다.
vpn_softether: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::2ac:e9ff:fe7e:289e prefixlen 64 scopeid 0x20<link>
ether 00:ac:e9:7e:28:9e txqueuelen 1000 (Ethernet)
RX packets 12 bytes 864 (864.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 20 bytes 1632 (1.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
내 /etc/sysconfig/network-scripts/ifcfg-vpn_softether가 있습니다.
DEVICE="vpn_softether"
HWADDR="00:ac:e9:7e:28:9e"
ONBOOT="yes"
BOOTPROTO=static
NM_CONTROLLED="no"
IPADDR="10.38.0.50"
NETMASK="255.255.255.0"
다음을 실행해야 합니다.
ifdown vpn_softether && ifup vpn_softether
인터페이스에서 고정 IP를 가질 수 있습니다.
vpn_softether: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.38.0.50 netmask 255.255.255.0 broadcast 10.38.0.255
inet6 fe80::2ac:e9ff:fe7e:289e prefixlen 64 scopeid 0x20<link>
ether 00:ac:e9:7e:28:9e txqueuelen 1000 (Ethernet)
RX packets 33 bytes 2506 (2.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 69 bytes 12308 (12.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
몇 가지 팁을 알려주시면 감사하겠습니다 :)
답변1
다음에 추가:
/usr/local/vpnclient/vpnclient start
ifdown vpn_softether && ifup vpn_softethe
스크립트에 추가한 다음 systemd 서비스 파일의 ExecStart 줄에서 생성된 스크립트를 참조합니다.
답변2
고마워요 라만!
누군가에게 도움이 될 수 있으며 팁이 있습니다.
수정된 systemD 서비스:
[Unit]
Description=SoftEther VPN Client
After=network.target auditd.service
ConditionPathExists=!/usr/local/vpnclient/vpnclient/do_not_run
[Service]
Type=forking
EnvironmentFile=-/usr/local/vpnclient/vpnclient
ExecStart=/usr/local/vpnclient/restart_vpn_eth.sh
ExecStop=/usr/local/vpnclient/vpnclient stop
KillMode=process
Restart=on-failure
# Hardening
PrivateTmp=yes
ProtectHome=yes
ProtectSystem=full
ReadOnlyDirectories=/
ReadWriteDirectories=-/usr/local/vpnclient/vpnclient
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW CAP_SYS_NICE CAP_SYS_ADMIN CAP_SETUID
[Install]
WantedBy=multi-user.target
그리고 스크립트:
#!/bin/sh
/usr/local/vpnclient/vpnclient start
sleep 5
ifdown vpn_cent
sleep 5
ifup vpn_cent