14.04 용으로 작성된 지침에 따라 18.04로 새 서버를 설정하고 있습니다. 다음 단계까지 있습니다.
/sbin/iptables -A FORWARD -p tcp --destination-port 80 -j ACCEPT
/sbin/iptables -t nat -A PREROUTING -j REDIRECT -p tcp --destination-port 80 --to-ports 8080
/sbin/iptables-save
# To save permanently (reset-persistent):
sudo sh -c "iptables-save > /etc/iptables.rules"
# Modify in /etc/network/interfaces
# Add this line:
pre-up iptables-restore < /etc/iptables.rules
# As below:
# The loopback network interface
auto lo
iface lo inet loopback
pre-up iptables-restore < /etc/iptables.rules
# The primary network interface
auto eth0 eth1
iface eth0 inet static
address XXX.XXX.XX.XXX
netmask 255.255.255.0
gateway XXX.XXX.XX.1
dns-nameservers 8.8.4.4 8.8.8.8 XXX.XXX.0.3
iface eth1 inet static
address XX.XXX.67.47
netmask 255.255.0.0
그러나 18.04는 netplan이라는 것을 사용하여 다른 방식으로 작업을 수행합니다.
14.04에서 일을 어떻게했는지 되 돌리는 방법과 관련된 질문과 답변을 찾았지만 같은 작업을 새로운 방식으로하는 것이 더 나은지 궁금합니다.
netplan을 사용하여 이전 방식으로 수행중인 작업을 어떻게 할 수 있습니까?
Netplan은 후크 스크립트를 지원하지 않습니다.
https://netplan.io/faq#use-pre-up-post-up-etc-hook-scripts
해결 방법은 networkd-dispatcher를 사용하는 것입니다. 위의 FAQ는이를 수행하는 방법에 대한 예를 제공합니다.
다음은 networkd-dispatcher를 사용하여 /etc/networkd-dispatcher/routable.d/50-ifup-hooks에 설치된 스크립트를 통해 기존 ifup 후크를 실행하는 예입니다.
#!/bin/sh
for d in up post-up; do
hookdir=/etc/network/if-${d}.d
[ -e $hookdir ] && /bin/run-parts $hookdir
done
exit 0
마찬가지로, 다음은 /etc/networkd-dispatcher/off.d/50-ifdown-hooks에 설치된 ifdown 후크의 예입니다.
#!/bin/sh
for d in down post-down; do
hookdir=/etc/network/if-${d}.d
[ -e $hookdir ] && /bin/run-parts $hookdir
done
exit 0
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다