{"id":532,"date":"2018-10-29T00:52:45","date_gmt":"2018-10-28T15:52:45","guid":{"rendered":"http:\/\/www7390uo.sakura.ne.jp\/wordpress\/?p=532"},"modified":"2022-07-17T10:37:55","modified_gmt":"2022-07-17T01:37:55","slug":"%e3%83%9e%e3%82%b7%e3%83%b3%e5%86%8d%e8%b5%b7%e5%8b%95%e6%99%82%e3%81%absystemd%e3%81%a7%e4%bb%a5%e3%81%a3%e3%81%a6iptables%e3%81%ae%e3%83%ab%e3%83%bc%e3%83%ab%e3%82%92%e4%bf%9d%e5%ad%98%e3%83%bb","status":"publish","type":"post","link":"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/archives\/532","title":{"rendered":"\u4eee\u60f3\u30de\u30b7\u30f3\u518d\u8d77\u52d5\u6642\u306bsystemd\u3067\u4ee5\u3063\u3066iptables\u306e\u30eb\u30fc\u30eb\u3092\u4fdd\u5b58\u30fb\u9069\u7528"},"content":{"rendered":"\n<p>OS: Ubuntu Server 18.04.1 LTS<br>VMware Workstation Pro 14.1.1 build-7528167<\/p>\n\n\n\n<p>\u4ee5\u524d\u306fifupdown\u3067iptables\u306e\u30eb\u30fc\u30eb\u3092\u4fdd\u5b58\u30fb\u9069\u7528\u3057\u3066\u3044\u305f\u3051\u308c\u3069\u3082\u3001\u8fd1\u9803\u306fnetplan\u306e\u53f0\u982d\u306b\u3088\u3063\u3066\u6d41\u5100\u304c\u7570\u306a\u308b\u3088\u3046\u3067\u3042\u308b\u3002netplan\u306f2018\u5e7410\u67082\u65e5\u73fe\u5728\u3067if-up.d\u3084if-down.d\u306e\u3088\u3046\u306a\u4ed5\u7d44\u307f\u3092\u6301\u3061\u5408\u308f\u305b\u3066\u3044\u306a\u3044\u3068\u3044\u3046\u3002\u4ee3\u308f\u308a\u306bnetworkd-dispatcher\u3092\u4f7f\u3046\u624b\u304c\u3042\u308b\u6a21\u69d8\u3067\u3042\u308b\u3002<\/p>\n\n\n\n<p>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u304c\u7121\u52b9\u306b\u306a\u3063\u305f\u969b\u306b\u52d5\u304d\u51fa\u3059\u306e\u306f <code>\/usr\/lib\/networkd-dispatcher\/off.d\/<\/code> \u914d\u4e0b\u306b\u8a2d\u7f6e\u3057\u305f\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3001\u6709\u52b9\u3068\u306a\u3063\u305f\u5834\u5408\u306f <code>\/usr\/lib\/networkd-dispatcher\/routable.d\/<\/code> \u914d\u4e0b\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3042\u308b\u3068\u3044\u3046\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/wp-content\/uploads\/2018\/11\/networkd-dispatcher.png\"><img loading=\"lazy\" decoding=\"async\" width=\"424\" height=\"425\" src=\"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/wp-content\/uploads\/2018\/11\/networkd-dispatcher.png\" alt=\"\" class=\"wp-image-534\" srcset=\"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/wp-content\/uploads\/2018\/11\/networkd-dispatcher.png 424w, https:\/\/www7390uo.sakura.ne.jp\/wordpress\/wp-content\/uploads\/2018\/11\/networkd-dispatcher-300x300.png 300w, https:\/\/www7390uo.sakura.ne.jp\/wordpress\/wp-content\/uploads\/2018\/11\/networkd-dispatcher-150x150.png 150w\" sizes=\"auto, (max-width: 424px) 100vw, 424px\" \/><\/a><figcaption>\u56f31. <a href=\"https:\/\/netplan.io\/faq#use-pre-up-post-up-etc-hook-scripts\">Netplan frequently asked questions<\/a>\u306b\u3088\u308b\u5bfe\u5fdc\u8868<\/figcaption><\/figure>\n<\/div>\n\n\n<p>\u3068\u3053\u308d\u304cVMware\u4e0a\u306eUbuntu\u4eee\u60f3\u30de\u30b7\u30f3\u3067\u306foff.d\u914d\u4e0b\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u304c\u5168\u7136\u8d77\u52d5\u3057\u306a\u304b\u3063\u305f\u3002\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u6240\u6709\u6a29\u3092root\u306b\u3057\u3001\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u3082700\u306b\u30bb\u30c3\u30c8\u3057\u3066\u5fc5\u8981\u6761\u4ef6\u3092\u6e80\u305f\u3057\u3066\u3082\u3069\u3046\u3057\u3066\u3082\u30c0\u30e1\u3067\u3042\u308b\u3002\u624b\u52d5\u3067\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3092\u7121\u52b9\u306b\u3057\u305f\u5834\u5408\u306f\u78ba\u304b\u306b\u5b9f\u884c\u3055\u308c\u308b\u3051\u308c\u3069\u3082\u3001\u30b7\u30e3\u30c3\u30c8\u30c0\u30a6\u30f3\u3084\u518d\u8d77\u52d5\u6642\u306b\u306f\u4eee\u60f3\u30de\u30b7\u30f3\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u304c\u4f55\u6545\u304b\u7121\u52b9\u306b\u306a\u3089\u306a\u3044\u3002\u307e\u308b\u3067\u539f\u56e0\u304c\u308f\u304b\u3089\u306a\u3044\u304b\u3089\u3082\u3046systemd\u3067\u4ee5\u3063\u3066\u5bfe\u5fdc\u3057\u305f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo vi \/etc\/systemd\/system\/ipt-save.service\n[Unit]\nDescription=Save and restore iptables rules.\nAfter=network.target\nBefore=shutdown.target reboot.target\nRequires=network.target\n\n[Service]\nType=simple\nExecStart=\/bin\/sh -c <strong class=\"orange\">'<\/strong>\/sbin\/iptables-restore -c &lt; \/etc\/iptables.conf<strong class=\"orange\">'<\/strong>\nExecStop=\/bin\/sh -c <strong class=\"orange\">'<\/strong>\/sbin\/iptables-save -c &gt; \/etc\/iptables.conf<strong class=\"orange\">'<\/strong>\nRemainAfterExit=true\n\n[Install]\nWantedBy=multi-user.target<\/pre>\n\n\n\n<p>ExecStart\u3084ExecStop\u306e\u9805\u76ee\u3067\u306f\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u8a18\u53f7\u3092\u88f8\u3067\u8a18\u8ff0\u3059\u308b\u3068\u3001\u5b9f\u884c\u6642\u306b\u306f\u7121\u3044\u3082\u306e\u3068\u3057\u3066\u632f\u308b\u821e\u3063\u3066\u3044\u305f\u3002\u30b7\u30f3\u30b0\u30eb\u30af\u30a9\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u5305\u56f2\u5185\u3067\u3042\u308c\u3070\u6709\u52b9\u3067\u3042\u3063\u305f\u3002\u3042\u3068\u306f\u30e6\u30cb\u30c3\u30c8\u3092\u6709\u52b9\u306b\u3057\u3066\u7d42\u3044\u3067\u3042\u308b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo \/bin\/sh -c '\/sbin\/iptables-save -c &gt; \/etc\/iptables.conf'\n$ sudo systemctl enable ipt-save.service\n$ systemctl status ipt-save.service\n<strong class=\"green\">\u25cf<\/strong> ipt-save.service - Save and restore iptables rules.\n   Loaded: loaded (\/etc\/systemd\/system\/ipt-save.service; enabled; vendor preset: enabled)\n   Active: active (exited) since Tue 2018-10-02 21:51:22 JST; 29min ago\n(snip)<\/pre>\n\n\n\n<p>networkd-dispatcher\u306f\u601d\u3044\u901a\u308a\u306b\u306a\u3089\u306a\u3044\u3057systemd\u306f\u306a\u3093\u3060\u304b\u3068\u3063\u3064\u304d\u96e3\u3044\u3057\u5049\u3044\u3082\u306e\u306b\u9996\u3092\u7a81\u3063\u8fbc\u3093\u3067\u3057\u307e\u3063\u305f\u3068\u3044\u3046\u5fc3\u6301\u3061\u3067\u3042\u308b\u3002<\/p>\n\n\n\n<h3 class=\"link\">\u53c2\u8003:<\/h3>\n<ul>\n <li><a href=\"https:\/\/netplan.io\/faq#use-pre-up-post-up-etc-hook-scripts\">Use pre-up, post-up, etc. hook scripts<\/a><\/li>\n <li><a href=\"https:\/\/gitlab.com\/craftyguy\/networkd-dispatcher\">clayton craft \/ networkd-dispatcher\u30fbGitLab<\/a><\/li>\n <li><a href=\"http:\/\/manpages.ubuntu.com\/manpages\/bionic\/en\/man8\/networkd-dispatcher.8.html\">Ubuntu Manpage: networkd-dispatcher &#8211; Dispatcher service for systemd-networkd connection status changes<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>OS: Ubuntu Server 18.04.1 LTSVMware Workstation Pro 14.1.1 build-7528167 \u4ee5\u524d\u306fifupdown\u3067iptables\u306e\u30eb\u30fc\u30eb\u3092\u4fdd\u5b58\u30fb\u9069\u7528\u3057\u3066\u3044\u305f\u3051\u308c\u3069\u3082\u3001\u8fd1\u9803\u306fnetplan\u306e\u53f0\u982d\u306b\u3088\u3063\u3066\u6d41\u5100\u304c\u7570\u306a\u308b\u3088\u3046\u3067\u3042\u308b\u3002netplan\u306f2018\u5e7410\u67082\u65e5\u73fe\u5728\u3067if-up.d\u3084if-down.d\u306e\u3088\u3046\u306a\u4ed5\u7d44\u307f\u3092\u6301\u3061\u5408\u308f\u305b\u3066\u3044\u306a\u3044\u3068\u3044\u3046\u3002 &#8230; <a title=\"\u4eee\u60f3\u30de\u30b7\u30f3\u518d\u8d77\u52d5\u6642\u306bsystemd\u3067\u4ee5\u3063\u3066iptables\u306e\u30eb\u30fc\u30eb\u3092\u4fdd\u5b58\u30fb\u9069\u7528\" class=\"read-more\" href=\"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/archives\/532\" aria-label=\"\u4eee\u60f3\u30de\u30b7\u30f3\u518d\u8d77\u52d5\u6642\u306bsystemd\u3067\u4ee5\u3063\u3066iptables\u306e\u30eb\u30fc\u30eb\u3092\u4fdd\u5b58\u30fb\u9069\u7528 \u306b\u3064\u3044\u3066\u3055\u3089\u306b\u8aad\u3080\">\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[157],"tags":[254,212],"class_list":["post-532","post","type-post","status-publish","format-standard","hentry","category-linux","tag-iptables","tag-systemd"],"views":2680,"_links":{"self":[{"href":"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/wp-json\/wp\/v2\/posts\/532","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/wp-json\/wp\/v2\/comments?post=532"}],"version-history":[{"count":0,"href":"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/wp-json\/wp\/v2\/posts\/532\/revisions"}],"wp:attachment":[{"href":"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/wp-json\/wp\/v2\/media?parent=532"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/wp-json\/wp\/v2\/categories?post=532"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/wp-json\/wp\/v2\/tags?post=532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}