web-archive/AlpineLinux/Wireguard on Alpine.html
lauralani 46da301064
All checks were successful
ci/woodpecker/push/upload Pipeline was successful
initial commit
2023-09-01 08:20:19 +02:00

336 lines
No EOL
53 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html> <html class="client-js vector-animations-ready" dir=ltr lang=en><!--
Page saved with SingleFile
url: https://wiki.alpinelinux.org/wiki/Configure_a_Wireguard_interface_(wg)
saved date: Thu Mar 02 2023 17:12:11 GMT+0100 (Central European Standard Time)
--><meta charset=utf-8>
<title>Configure a Wireguard interface (wg) - Alpine Linux</title>
<style>.mw-ui-button{border:1px solid #a2a9b1;cursor:pointer;font-family:inherit;text-align:center;-webkit-appearance:none}.mw-ui-button:not(.mw-ui-icon-element){min-height:32px;min-width:4em;max-width:28.75em;padding:5px 12px}.mw-ui-button:not(:disabled){transition-property:background-color,color,border-color,box-shadow;transition-duration:100ms}.mw-ui-button:not(:disabled):visited{color:#202122}.mw-ui-button:not(:disabled):hover{background-color:#ffffff;color:#404244;border-color:#a2a9b1}.mw-ui-button:not(:disabled):focus{color:#202122;border-color:#3366cc;box-shadow:inset 0 0 0 1px #3366cc,inset 0 0 0 2px #ffffff;outline-width:0}.mw-ui-button:not(:disabled):focus::-moz-focus-inner{border-color:transparent;padding:0}.mw-ui-button:not(:disabled):active,.mw-ui-button:not(:disabled).is-on{background-color:#c8ccd1;color:#000000;border-color:#72777d;box-shadow:none}.mw-ui-button:disabled{background-color:#c8ccd1;color:#ffffff;border-color:#c8ccd1;cursor:default}.mw-ui-button.mw-ui-icon-element:not(.mw-ui-icon-with-label-desktop){color:transparent!important}.mw-ui-button.mw-ui-icon-element:not(.mw-ui-icon-with-label-desktop) span{display:block;position:absolute!important;clip:rect(1px,1px,1px,1px);width:1px;height:1px;margin:-1px;border:0;padding:0;overflow:hidden}@media all and (max-width:1000px){.mw-ui-button.mw-ui-icon-element span{display:block;position:absolute!important;clip:rect(1px,1px,1px,1px);width:1px;height:1px;margin:-1px;border:0;padding:0;overflow:hidden}}.mw-ui-button.mw-ui-quiet{background-color:transparent;color:#202122;border-color:transparent;font-weight:bold}.mw-ui-button.mw-ui-quiet:not(.mw-ui-icon-element),.mw-ui-button.mw-ui-quiet.mw-ui-progressive:not(.mw-ui-icon-element),.mw-ui-button.mw-ui-quiet.mw-ui-destructive:not(.mw-ui-icon-element){min-height:32px}input[type="checkbox"]:hover+.mw-ui-button.mw-ui-quiet,input[type="checkbox"]:hover+.mw-ui-button.mw-ui-quiet.mw-ui-progressive,input[type="checkbox"]:hover+.mw-ui-button.mw-ui-quiet.mw-ui-destructive,.mw-ui-button.mw-ui-quiet:hover,.mw-ui-button.mw-ui-quiet.mw-ui-progressive:hover,.mw-ui-button.mw-ui-quiet.mw-ui-destructive:hover{background-color:rgba(0,24,73,0.02745098);color:#202122;border-color:transparent}input[type="checkbox"]:focus+.mw-ui-button.mw-ui-quiet,input[type="checkbox"]:focus+.mw-ui-button.mw-ui-quiet.mw-ui-progressive,input[type="checkbox"]:focus+.mw-ui-button.mw-ui-quiet.mw-ui-destructive,.mw-ui-button.mw-ui-quiet:focus,.mw-ui-button.mw-ui-quiet.mw-ui-progressive:focus,.mw-ui-button.mw-ui-quiet.mw-ui-destructive:focus{color:#202122;border-color:#3366cc;box-shadow:inset 0 0 0 1px #3366cc,inset 0 0 0 2px #ffffff}input[type="checkbox"]:active+.mw-ui-button.mw-ui-quiet,input[type="checkbox"]:active+.mw-ui-button.mw-ui-quiet.mw-ui-progressive,input[type="checkbox"]:active+.mw-ui-button.mw-ui-quiet.mw-ui-destructive,.mw-ui-button.mw-ui-quiet:active,.mw-ui-button.mw-ui-quiet.mw-ui-progressive:active,.mw-ui-button.mw-ui-quiet.mw-ui-destructive:active{background-color:rgba(0,36,73,0.08235294);color:#000000;border-color:#72777d;box-shadow:none}.mw-ui-button.mw-ui-quiet:disabled,.mw-ui-button.mw-ui-quiet.mw-ui-progressive:disabled,.mw-ui-button.mw-ui-quiet.mw-ui-destructive:disabled,.mw-ui-button.mw-ui-quiet:disabled:hover,.mw-ui-button.mw-ui-quiet.mw-ui-progressive:disabled:hover,.mw-ui-button.mw-ui-quiet.mw-ui-destructive:disabled:hover,.mw-ui-button.mw-ui-quiet:disabled:active,.mw-ui-button.mw-ui-quiet.mw-ui-progressive:disabled:active,.mw-ui-button.mw-ui-quiet.mw-ui-destructive:disabled:active{background-color:transparent;color:#72777d;border-color:transparent}.mw-ui-icon{font-size:initial;position:relative;display:inline-block;box-sizing:content-box!important;width:1.25em;height:1.25em;min-width:1.25em;min-height:1.25em;flex-basis:1.25em;vertical-align:middle;line-height:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;-moz-appearance:none;-webkit-appearance:none;background-color:transparent;margin:0;padding:0}.mw-ui-icon:not(.mw-ui-button){border:0}.mw-ui-icon:before{content:"";display:block;width:100%;height:100%;min-width:1.25em;min-height:1.25em;background-repeat:no-repeat;background-size:1.25em 1.25em;background-position:center}.mw-ui-icon+span:not(:empty){margin-left:8px}.mw-ui-icon-element{border-radius:2px;padding:0.75em;transition:background-color 100ms}.mw-ui-icon-element:focus,.mw-ui-icon-element:active,.mw-ui-icon-element:visited{color:transparent}.mw-ui-icon-element:active{background-color:rgba(0,0,0,0.03)}@media (hover:hover){.mw-ui-icon-element:not(.disabled):hover{background-color:rgba(0,0,0,0.03)}}.mw-ui-icon-wikimedia-ellipsis:before{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABmJLR0QA/wD/AP+gvaeTAAAAQElEQVQ4je3PsQkAIQxA0cdNp7j/Anp7nI2VlYJwFnmQ6hNCCOEeBS8a8onW8I2p09JWe3ZfWZXHtYp0qIXwmw749BlfpvCfqgAAAABJRU5ErkJggg==);background-image:linear-gradient(transparent,transparent),url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgdmlld0JveD0iMCAwIDIwIDIwIj48dGl0bGU+CgkJZWxsaXBzaXMKCTwvdGl0bGU+PGcgZmlsbD0iIzAwMCI+PGNpcmNsZSBjeD0iMTAiIGN5PSIxMCIgcj0iMiIvPjxjaXJjbGUgY3g9IjMiIGN5PSIxMCIgcj0iMiIvPjxjaXJjbGUgY3g9IjE3IiBjeT0iMTAiIHI9IjIiLz48L2c+PC9zdmc+Cg==)}.mw-ui-icon-wikimedia-logIn:before{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABmJLR0QA/wD/AP+gvaeTAAAAhElEQVQ4jcWU0QmAMAwFr4q7qYPpjxO4gAO4kXWP+qEVQcSor3iQj0I4mqQNJKIGPBBehgeqo/CLLMYE4DZhEFXqMpFoxypsn4rv+gPQGfPMQgf0SiFADgwW4RMKYLwSyqcckZf8y1Ckz6Yx5IRYRhQqSPeXZ4HLHw8V6z77sgtLwaXOLCxJqxJMix9EAAAAAElFTkSuQmCC);background-image:linear-gradient(transparent,transparent),url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgdmlld0JveD0iMCAwIDIwIDIwIj48dGl0bGU+CgkJbG9nIGluCgk8L3RpdGxlPjxnIGZpbGw9IiMwMDAiPjxwYXRoIGQ9Ik0xIDExdjZjMCAxLjEuOSAyIDIgMmgxNGMxLjEgMCAyLS45IDItMlYzYzAtMS4xLS45LTItMi0ySDNjLTEuMSAwLTIgLjktMiAydjZoOFY1bDQuNzUgNUw5IDE1di00SDF6Ii8+PC9nPjwvc3ZnPgo=)}@media (prefers-reduced-motion:reduce){*,::before,::after{animation-delay:-0.01ms!important;animation-duration:0.01ms!important;animation-iteration-count:1!important;scroll-behavior:auto!important;transition-duration:0ms!important}}body{margin:0}main{display:block}@supports (text-decoration:underline dotted){abbr[title]{border-bottom:0;text-decoration:underline dotted}}pre,code{font-family:monospace,monospace}img{border:0}button,input{margin:0}button::-moz-focus-inner,[type="button"]::-moz-focus-inner,[type="reset"]::-moz-focus-inner,[type="submit"]::-moz-focus-inner{border-style:none;padding:0}@media screen{html,body{height:100%}:focus{outline-color:#3366cc}html{font-size:100%}html,body{font-family:sans-serif}ul{list-style-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI1IiBoZWlnaHQ9IjEzIj4KCTxjaXJjbGUgY3g9IjIuNSIgY3k9IjkiIHI9IjIuNSIgZmlsbD0iIzIwMjEyMiIvPgo8L3N2Zz4K)}pre{line-height:1.3}.mw-jump-link:not(:focus){display:block;position:absolute!important;clip:rect(1px,1px,1px,1px);width:1px;height:1px;margin:-1px;border:0;padding:0;overflow:hidden}.mw-body h1,.mw-body-content h2{margin-bottom:0.25em;padding:0;font-family:"Linux Libertine","Georgia","Times",serif;line-height:1.3}.mw-body h1:lang(ja),.mw-body-content h1:lang(ja),.mw-body-content h2:lang(ja),.mw-body h1:lang(he),.mw-body-content h1:lang(he),.mw-body-content h2:lang(he),.mw-body h1:lang(ko),.mw-body-content h1:lang(ko),.mw-body-content h2:lang(ko){font-family:sans-serif}.mw-body h1:lang(my),.mw-body-content h1:lang(my),.mw-body-content h2:lang(my){line-height:normal}.mw-body h1{font-size:1.8em}.vector-body{font-size:calc(1em*0.875);line-height:1.6}.vector-body h2{margin-top:1em;font-size:1.5em}.vector-body p{margin:0.5em 0}.mw-parser-output a.external{background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMiIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDEyIDEyIj4KCTx0aXRsZT4KCQlleHRlcm5hbCBsaW5rCgk8L3RpdGxlPgoJPHBhdGggZmlsbD0iIzM2YyIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMTEgMUg2bDIgMiAuMy4zLTQgNCAuNi43IDQtNEg5bDIgMlYxWk0yIDJoMnYxSDJ2N2g3VjhoMXYyYTEgMSAwIDAgMS0xIDFIMmExIDEgMCAwIDEtMS0xVjNhMSAxIDAgMCAxIDEtMVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPgo8L3N2Zz4K);background-position:center right;background-repeat:no-repeat;background-size:0.857em;padding-right:1em}.mw-indicators{font-size:0.875em;line-height:1.6;position:relative;float:right}#siteNotice{font-size:0.8em;margin:24px 0;position:relative;text-align:center}.mw-portlet .vector-menu-heading{display:none}.mw-portlet ul{list-style:none;margin:0}.vector-menu-dropdown{position:relative}.vector-menu-dropdown .vector-menu-content{position:absolute;top:100%;left:-1px;opacity:0;height:0;visibility:hidden;overflow:hidden;min-width:100%;margin:0;padding:0;z-index:3}.vector-menu-dropdown .vector-menu-content-list{list-style:none}.vector-menu-checkbox{cursor:pointer;position:absolute;top:0;left:0;z-index:1;opacity:0;width:100%;height:100%;margin:0;padding:0;display:none}.vector-menu-checkbox:checked~.vector-menu-content{opacity:1;visibility:visible;height:auto}:not(:checked)>.vector-menu-checkbox{display:block}.vector-menu-checkbox:focus+.vector-menu-heading{outline:dotted 1px;outline:auto -webkit-focus-ring-color}.vector-search-box-inner{position:relative;height:100%}.vector-search-box-input{background-color:rgba(255,255,255,0.5);color:#000000;width:100%;height:2.15384615em;box-sizing:border-box;border:1px solid #a2a9b1;border-radius:2px;padding:5px 2.15384615em 5px 0.4em;box-shadow:inset 0 0 0 1px transparent;font-family:inherit;font-size:0.8125em;direction:ltr;transition-property:border-color,box-shadow;transition-duration:250ms;-webkit-appearance:none;-moz-appearance:textfield}.vector-search-box-inner:hover .vector-search-box-input{border-color:#72777d}.vector-search-box-input:focus,.vector-search-box-inner:hover .vector-search-box-input:focus{outline:0;border-color:#3366cc;box-shadow:inset 0 0 0 1px #3366cc}.vector-search-box-input::-webkit-input-placeholder{color:#72777d;opacity:1}.vector-search-box-input::-moz-placeholder{color:#72777d;opacity:1}.vector-search-box-input::placeholder{color:#72777d;opacity:1}.vector-search-box-input::-webkit-search-decoration,.vector-search-box-input::-webkit-search-cancel-button,.vector-search-box-input::-webkit-search-results-button,.vector-search-box-input::-webkit-search-results-decoration{display:none}.searchButton{background-color:transparent;position:absolute;top:1px;bottom:1px;right:1px;min-width:28px;width:2.15384615em;border:0;padding:0;cursor:pointer;font-size:0.8125em;direction:ltr;text-indent:-99999px;white-space:nowrap;overflow:hidden;z-index:1}.searchButton[name="go"]{background:no-repeat center/1.23076923em url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgdmlld0JveD0iMCAwIDIwIDIwIj4KCTx0aXRsZT4KCQlzZWFyY2gKCTwvdGl0bGU+Cgk8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xMi4yIDEzLjZhNyA3IDAgMSAxIDEuNC0xLjRsNS40IDUuNC0xLjQgMS40LTUuNC01LjR6TTEzIDhBNSA1IDAgMSAxIDMgOGE1IDUgMCAwIDEgMTAgMHoiLz4KPC9zdmc+Cg==);opacity:0.67}.vector-search-box-collapses>div{display:none}.mw-footer{direction:ltr}.mw-footer ul{list-style:none;margin:0;padding:0}.mw-footer li{color:#202122;margin:0;padding:0.5em 0;font-size:0.75em}#footer-icons{float:right}#footer-icons li{float:left;margin-left:0.5em;line-height:2;text-align:right}#footer-info li{line-height:1.4}#footer-places li{float:left;margin-right:1em;line-height:2}}@media screen and (min-width:1000px){.vector-search-box-collapses>div{display:block}}@media screen{body{background-color:#f8f9fa;color:#202122;overflow-y:scroll}.mw-body{direction:ltr}.mw-body{border-top:1px solid transparent;margin-top:-1px;padding:0.5em 0.5em 1.5em}.mw-body .firstHeading{overflow:visible;margin-bottom:0}.mw-header{position:relative;z-index:4}.mw-body-content{margin-top:16px}.mw-body,.mw-footer{margin-left:0}.mw-indicators{z-index:1}.mw-body-header:after,.mw-body-subheader:after{clear:both;content:"";display:block}.vector-body{position:relative;z-index:0}#left-navigation{float:left;margin-left:-8px}#right-navigation{float:right;margin-right:-8px}#right-navigation .vector-menu-content{left:auto;right:-1px}.mw-footer{border-top:1px solid #a2a9b1;padding:0.75em}.mw-page-container{position:relative;z-index:0;max-width:94.625em;min-height:100%;margin-left:auto;margin-right:auto;padding:0.05px 1em;background-color:#ffffff;min-width:26.25em}.mw-content-container{max-width:60em}.mw-article-toolbar-container{display:flow-root;border-bottom:1px solid #eaecf0}.mw-article-toolbar-container>div{font-size:0.8125em}.mw-article-toolbar-container .mw-portlet-views{display:none}@keyframes search-loader-progress-bar{0%{background-size:0 2px;background-position:-10%0}30%{background-size:30% 2px;background-position:-10%0}70%{background-size:30% 2px;background-position:110%0}100%{background-size:0 2px;background-position:110%0}}.vector-search-box{font-size:calc(1em*0.875);flex-grow:1}.vector-search-box-vue .vector-search-box-input,.vector-search-box-vue .searchButton{font-size:inherit}.vector-search-box-vue .vector-search-box-input{height:32px}.vector-search-box-vue .searchButton{background-size:1.42857143em auto}.client-js .vector-search-box-vue .vector-search-box-input{padding-left:36px;padding-right:8px}.client-js .vector-search-box-vue .searchButton{pointer-events:none;right:auto;top:0;bottom:0;width:36px;opacity:0.51}.client-js .vector-search-box-vue .vector-search-box-input:focus~.searchButton{opacity:0.87}.client-js .vector-search-box-vue.vector-search-box-show-thumbnail>div{max-width:37.42857143em}.client-js .vector-search-box-vue.vector-search-box-show-thumbnail.vector-search-box-auto-expand-width .searchButton{left:25px}.client-js .vector-search-box-vue.vector-search-box-show-thumbnail.vector-search-box-auto-expand-width .vector-search-box-input{margin-left:24px;width:calc(100% - 24px)}.client-js .vector-search-box-vue.vector-search-box-show-thumbnail:not(.vector-search-box-auto-expand-width) .vector-search-box-input,.client-js .vector-search-box-vue.vector-search-box-show-thumbnail.vector-search-box-auto-expand-width .vector-search-box-input:focus{margin-left:0;padding-left:calc(36px + 24px);width:100%}.client-js .vector-search-box-vue.vector-search-box-show-thumbnail:not(.vector-search-box-auto-expand-width) .vector-search-box-input~.searchButton,.client-js .vector-search-box-vue.vector-search-box-show-thumbnail.vector-search-box-auto-expand-width .vector-search-box-input:focus~.searchButton{left:14px}.mw-checkbox-hack-button{display:inline-block;cursor:pointer}.sidebar-toc,.sidebar-toc:after{width:220px;margin-left:0}.sidebar-toc,.sidebar-toc:after{margin-left:-0.75em}#mw-sidebar-button:before{opacity:0.67;background-image:url(data:image/svg+xml,%3Csvg\ xmlns=%22http://www.w3.org/2000/svg%22\ width=%2220%22\ height=%2220%22\ viewBox=%220\ 0\ 20\ 20%22%3E\ %3Ctitle%3E\ chevron\ %3C/title%3E\ %3Cpath\ d=%22m9\ 2\ 1.3\ 1.3L3.7\ 10l6.6\ 6.7L9\ 18l-8-8\ 8-8zm8.5\ 0L19\ 3.3\ 12.2\ 10l6.7\ 6.7-1.4\ 1.3-8-8\ 8-8z%22/%3E\ %3C/svg%3E)}#mw-sidebar-checkbox:not(:checked)~.mw-header #mw-sidebar-button:before{background-image:url(data:image/svg+xml,%3Csvg\ xmlns=%22http://www.w3.org/2000/svg%22\ width=%2220%22\ height=%2220%22\ viewBox=%220\ 0\ 20\ 20%22%3E\ %3Ctitle%3E\ menu\ %3C/title%3E\ %3Cpath\ d=%22M1\ 3v2h18V3zm0\ 8h18V9H1zm0\ 6h18v-2H1z%22/%3E\ %3C/svg%3E)}#mw-sidebar-button:hover:before{opacity:1}.vector-user-links{display:flex;align-items:center;position:relative;justify-content:flex-end;flex-shrink:1;font-size:0.875em}.vector-user-links .mw-ui-button{align-items:center}.vector-user-links .mw-list-item{margin:0}.vector-user-menu .vector-menu-content{left:auto;right:0;min-width:200px}.vector-user-menu-overflow .vector-menu-content-list{display:flex;align-items:center}.vector-user-menu-more a:not(.mw-ui-button):not(.mw-echo-notifications-badge),.vector-user-menu-overflow a:not(.mw-ui-button):not(.mw-echo-notifications-badge){margin:0 8px}.vector-user-menu-login{border-bottom:1px solid #eaecf0}.mw-header{min-height:3.125em;padding:8px 0;display:flex;flex-wrap:nowrap;align-items:center}.mw-header #mw-sidebar-button{margin-right:0.75em}.mw-header-content,.mw-header-aside{display:flex;align-items:center}.mw-header-aside{float:left}.mw-header-content{flex-grow:1}.mw-footer-container{padding-top:50px;padding-bottom:82px}.vector-menu-dropdown .vector-menu-heading{display:flex}.vector-menu-dropdown .vector-menu-heading:after,.mw-interlanguage-selector:after{content:"";background:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMiIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDEyIDEyIj4KCTxwYXRoIGZpbGw9IiMyMDIxMjIiIGQ9Im0xMS4wNSAzLjk5Ni0uOTY1LTEuMDUzLTQuMDM1IDMuODYtMy45NDctMy44NkwxLjA1IDMuOTk2bDUgNSA1LTUiLz4KPC9zdmc+Cg==)100% 50%no-repeat;width:1.23076923em;height:1.23076923em}.vector-menu-dropdown .vector-menu-content{background-color:#ffffff;border:1px solid #a2a9b1;box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);transition-property:opacity;transition-duration:100ms}.vector-user-menu-login a{min-height:32px;display:flex;align-items:center;padding:0 12px;white-space:nowrap;color:#3366cc}.vector-user-menu-logout a:visited,.vector-user-menu-create-account a:visited,.vector-user-menu-login a:visited,.vector-menu-dropdown .mw-list-item a:visited{color:#3366cc}.vector-menu-tabs{float:left}.vector-menu-tabs .mw-list-item a{color:#3366cc}.vector-menu-tabs .mw-list-item a:focus,.vector-menu-tabs .mw-list-item a:hover{text-decoration:none;border-bottom:1px solid}.vector-menu-tabs .mw-list-item.selected a,.vector-menu-tabs .mw-list-item.selected a:visited{color:#202122;border-bottom:1px solid}.vector-menu-tabs .mw-list-item{float:left;white-space:nowrap;margin:0 8px}.vector-menu-tabs .mw-list-item>a{display:inline-flex;position:relative;padding:18px 0 7px 0;margin-bottom:-1px;cursor:pointer;border-bottom:1px solid transparent;max-height:3.15384615em;box-sizing:border-box;font-size:inherit;font-weight:normal}@keyframes rotate{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}.mw-table-of-contents-container{align-self:start;height:100%}.vector-sticky-toc-container{position:sticky;top:0}.sidebar-toc{max-height:75vh;padding:20px 12px 20px calc(15px + 0.75em);box-sizing:border-box;overflow:auto;background-color:#ffffff}.sidebar-toc .sidebar-toc-header{padding-bottom:12px}.sidebar-toc .sidebar-toc-title{color:#54595d;font-size:0.875em;margin:0;padding:0;border:0}.sidebar-toc .sidebar-toc-link{word-break:break-word;color:#3366cc;display:block}.sidebar-toc .sidebar-toc-list-item-active>.sidebar-toc-link{color:#202122;font-weight:bold;width:calc(100% + 12px)}.sidebar-toc .sidebar-toc-text{padding:4px 0}.sidebar-toc .sidebar-toc-contents,.sidebar-toc .sidebar-toc-list{margin:0;list-style:none;line-height:18px}.sidebar-toc .sidebar-toc-list-item{display:block;position:relative;list-style-type:none}.sidebar-toc .sidebar-toc-list-item.sidebar-toc-level-1{padding-left:0}.sidebar-toc .sidebar-toc-list-item a{font-size:0.875em}.sidebar-toc{z-index:3}.vector-toc-collapse-button{display:none;border:0;padding:0;background-color:transparent;color:#3366cc;cursor:pointer}.vector-toc-collapse-button:hover,.vector-toc-uncollapse-button:hover{color:#447ff5}.vector-toc-collapse-button:before,.vector-toc-uncollapse-button:before{content:"[";color:#54595d}.vector-toc-collapse-button:after,.vector-toc-uncollapse-button:after{content:"]";color:#54595d}}@media screen and (min-width:1000px){.mw-page-container{padding-left:2em;padding-right:2em}}@media screen and (min-width:1200px){.mw-page-container{padding-left:2.5em;padding-right:2.5em}}@media screen and (min-width:1000px){.mw-page-container-inner{display:grid;width:100%;grid-template:min-content min-content min-content 1fr min-content/232px 20px minmax(0,1fr);grid-template-areas:"header header header""sitenotice sitenotice sitenotice""sidebar gutter content""toc gutter content""footer footer footer"}.mw-body{padding-left:0}.vector-sitenotice-container{grid-area:sitenotice}.mw-table-of-contents-container{grid-area:toc}.mw-header{grid-area:header}.vector-sidebar-container{grid-area:sidebar}.mw-content-container{grid-area:content}.mw-footer-container{grid-area:footer}}@media screen and (min-width:1200px){.mw-page-container-inner{grid-template-columns:284px 20px minmax(0,1fr)}}@media screen and (min-width:720px){.mw-article-toolbar-container .mw-portlet-views:not(.emptyPortlet){display:block}}@media screen and (min-width:1200px){.sidebar-toc,.sidebar-toc:after{width:244px;margin-left:0.75em}}@media screen and (min-width:1200px){.sidebar-toc,.sidebar-toc:after{margin-left:0}}@media screen and (max-width:719px){.vector-user-menu-overflow .user-links-collapsible-item{display:none}}@media screen and (min-width:1200px){.mw-header .vector-search-box:not(.vector-search-box-auto-expand-width),html:not(.client-js) .mw-header .vector-search-box{padding-left:24px}}@media screen and (min-width:1000px){.mw-header .vector-search-box{margin-right:12px}}@media screen and (min-width:1000px){.vector-toc-not-collapsed .vector-sticky-toc-container{padding-top:1.5em}.vector-toc-not-collapsed #mw-sidebar-checkbox:not(:checked)~.mw-table-of-contents-container .vector-sticky-toc-container{margin-top:1.5em}}@media screen and (min-width:1000px){.vector-toc-not-collapsed .sidebar-toc:after{content:"";display:block;position:absolute;bottom:0;left:0;right:0;height:30px;background:linear-gradient(rgba(255,255,255,0),#ffffff);background-repeat:no-repeat;background-position:-12px;pointer-events:none}}@media screen and (max-width:999px){.vector-sticky-toc-container{position:relative}.mw-table-of-contents-container .sidebar-toc{display:none;margin:0;border:1px solid #a2a9b1}#vector-toc-collapsed-checkbox:checked~.mw-table-of-contents-container .sidebar-toc{display:block}.vector-below-page-title .sidebar-toc{position:fixed}.vector-below-page-title .sidebar-toc{top:36px;left:6px}}@media screen and (min-width:1000px){@supports (display:grid){.client-js .vector-toc-collapsed #vector-toc-collapsed-button{display:block}.client-js .vector-toc-collapsed .mw-table-of-contents-container.mw-sticky-header-element,.client-js .vector-toc-collapsed .vector-sticky-toc-container{position:relative}.client-js .vector-toc-collapsed .mw-table-of-contents-container .sidebar-toc{display:none;position:absolute;margin:0;border:1px solid #a2a9b1}.client-js .vector-toc-collapsed #vector-toc-collapsed-checkbox:checked~.mw-table-of-contents-container .sidebar-toc{display:block}.client-js .vector-toc-collapsed .mw-table-of-contents-container{grid-area:content}.client-js .vector-toc-collapsed .mw-table-of-contents-container .sidebar-toc{top:calc(36px + 8px);left:-0.75em}body:not(.vector-sticky-header-visible).vector-below-page-title.client-js .vector-toc-collapsed #vector-toc-collapsed-button,body:not(.vector-sticky-header-visible).vector-below-page-title.client-js .vector-toc-collapsed .sidebar-toc{position:fixed}body:not(.vector-sticky-header-visible).vector-below-page-title.client-js .vector-toc-collapsed #vector-toc-collapsed-button{top:0;left:0;margin:0}body:not(.vector-sticky-header-visible).vector-below-page-title.client-js .vector-toc-collapsed .sidebar-toc{top:36px;left:6px}.client-js .vector-toc-collapsed .vector-toc-uncollapse-button{display:inline-block}.client-js .vector-toc-not-collapsed .vector-toc-collapse-button{display:inline-block}}}@media all{.mw-logo{display:flex;height:100%;align-items:center;min-width:13.875em}.mw-logo-container{float:left;max-width:120px}.mw-logo-wordmark{display:block;margin:0 auto}}@media all and (min-width:720px){.mw-logo-container{max-width:none}}.mw-table-of-contents-container{display:none}@supports (display:grid){.mw-table-of-contents-container{display:block}}@media screen{.mw-parser-output a.external{color:#3366cc}.mw-parser-output a.extiw:visited,.mw-parser-output a.external:visited{color:#795cb2}.mw-parser-output a.extiw:active,.mw-parser-output a.external:active{color:#faa700}.mw-body-content:after{clear:both;content:"";display:block}#catlinks{text-align:left}.catlinks{border:1px solid #a2a9b1;background-color:#f8f9fa;padding:5px;margin-top:1em;clear:both}.catlinks ul{display:inline;margin:0;padding:0;list-style:none}.catlinks li{display:inline-block;line-height:1.25em;border-left:1px solid #a2a9b1;margin:0.125em 0;padding:0 0.5em}.catlinks li:first-child{padding-left:0.25em;border-left:0}a{text-decoration:none;color:#3366cc;background:none}a:not([href]){cursor:pointer}a:visited{color:#795cb2}a:active{color:#faa700}a:hover,a:focus{text-decoration:underline}a:lang(ar),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}img{border:0;vertical-align:middle}h1,h2{color:#000;margin:0;padding-top:0.5em;padding-bottom:0.17em;overflow:hidden}h1,h2{margin-bottom:0.6em;border-bottom:1px solid #a2a9b1}h1{font-size:188%;font-weight:normal}h2{font-size:150%;font-weight:normal}p{margin:0.4em 0 0.5em 0}ul{margin:0.3em 0 0 1.6em;padding:0}li{margin-bottom:0.1em}pre,code{font-family:monospace,monospace}pre,code{background-color:#f8f9fa;color:#000;border:1px solid #eaecf0}code{border-radius:2px;padding:1px 4px}pre{padding:1em;white-space:pre-wrap;overflow-x:hidden;word-wrap:break-word}table{font-size:100%}form{border:0;margin:0}@counter-style meetei{system:numeric;symbols:"꯰""꯱""꯲""꯳""꯴""꯵""꯶""꯷""꯸""꯹";suffix:") "}@counter-style santali{system:numeric;symbols:"᱐""᱑""᱒""᱓""᱔""᱕""᱖""᱗""᱘""᱙"}@counter-style myanmar_with_period{system:numeric;symbols:"""၁""၂""၃""၄""၅""၆""၇""၈""၉";suffix:"။ "}.mw-content-ltr ul{margin:0.3em 0 0 1.6em;padding:0}h1:lang(anp),h1:lang(as),h1:lang(bh),h1:lang(bho),h1:lang(blk),h1:lang(bn),h1:lang(gu),h1:lang(hi),h1:lang(kjp),h1:lang(kn),h1:lang(ks),h1:lang(ksw),h1:lang(ml),h1:lang(mr),h1:lang(my),h1:lang(mai),h1:lang(mnw),h1:lang(ne),h1:lang(new),h1:lang(or),h1:lang(pa),h1:lang(pi),h1:lang(sa),h1:lang(shn),h1:lang(syl),h1:lang(ta),h1:lang(te){line-height:1.6em!important}h2:lang(anp),h2:lang(as),h2:lang(bh),h2:lang(bho),h2:lang(blk),h2:lang(bn),h2:lang(gu),h2:lang(hi),h2:lang(kjp),h2:lang(kn),h2:lang(ks),h2:lang(ksw),h2:lang(ml),h2:lang(mr),h2:lang(my),h2:lang(mai),h2:lang(mnw),h2:lang(ne),h2:lang(new),h2:lang(or),h2:lang(pa),h2:lang(pi),h2:lang(sa),h2:lang(shn),h2:lang(syl),h2:lang(ta),h2:lang(te),h3:lang(anp),h3:lang(as),h3:lang(bh),h3:lang(bho),h3:lang(blk),h3:lang(bn),h3:lang(gu),h3:lang(hi),h3:lang(kjp),h3:lang(kn),h3:lang(ks),h3:lang(ksw),h3:lang(ml),h3:lang(mr),h3:lang(my),h3:lang(mai),h3:lang(mnw),h3:lang(ne),h3:lang(new),h3:lang(or),h3:lang(pa),h3:lang(pi),h3:lang(sa),h3:lang(shn),h3:lang(syl),h3:lang(ta),h3:lang(te),h4:lang(anp),h4:lang(as),h4:lang(bh),h4:lang(bho),h4:lang(blk),h4:lang(bn),h4:lang(gu),h4:lang(hi),h4:lang(kjp),h4:lang(kn),h4:lang(ks),h4:lang(ksw),h4:lang(ml),h4:lang(mr),h4:lang(my),h4:lang(mai),h4:lang(mnw),h4:lang(ne),h4:lang(new),h4:lang(or),h4:lang(pa),h4:lang(pi),h4:lang(sa),h4:lang(shn),h4:lang(syl),h4:lang(ta),h4:lang(te),h5:lang(anp),h5:lang(as),h5:lang(bh),h5:lang(bho),h5:lang(blk),h5:lang(bn),h5:lang(gu),h5:lang(hi),h5:lang(kjp),h5:lang(kn),h5:lang(ks),h5:lang(ksw),h5:lang(ml),h5:lang(mr),h5:lang(my),h5:lang(mai),h5:lang(mnw),h5:lang(ne),h5:lang(new),h5:lang(or),h5:lang(pa),h5:lang(pi),h5:lang(sa),h5:lang(shn),h5:lang(syl),h5:lang(ta),h5:lang(te),h6:lang(anp),h6:lang(as),h6:lang(bh),h6:lang(bho),h6:lang(blk),h6:lang(bn),h6:lang(gu),h6:lang(hi),h6:lang(kjp),h6:lang(kn),h6:lang(ks),h6:lang(ksw),h6:lang(ml),h6:lang(mr),h6:lang(my),h6:lang(mai),h6:lang(mnw),h6:lang(ne),h6:lang(new),h6:lang(or),h6:lang(pa),h6:lang(pi),h6:lang(sa),h6:lang(shn),h6:lang(syl),h6:lang(ta),h6:lang(te){line-height:1.4em}h2:lang(th){line-height:1.6}}</style>
<meta name=generator content="MediaWiki 1.39.2">
<meta name=format-detection content="telephone=no">
<meta name=viewport content="width=1000">
<link rel=search type=application/opensearchdescription+xml href=https://wiki.alpinelinux.org/w/opensearch_desc.php title="Alpine Linux (en)">
<link rel=EditURI type=application/rsd+xml href="https://wiki.alpinelinux.org/w/api.php?action=rsd">
<link rel=license href=https://wiki.alpinelinux.org/wiki/MediaWiki:Copyright>
<link rel=alternate type=application/atom+xml title="Alpine Linux Atom feed" href="https://wiki.alpinelinux.org/w/index.php?title=Special:RecentChanges&amp;feed=atom">
<link rel=icon href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAATJQTFRF////AICAC1qADVmAFGJ2DVmADVl/EFiADVmADlmADVmAAAAADVmADVl+DVl/Dlp/F110DVl/DVmADVmADVl/DliADFd8DliADVl+DVuADVl/CVh7DVmADFuADVh/DVqADVmADVmADFmADVl/FVWAC1h+Dlh+AFVVDFiADVl/DluADFl9DVl/DViADVh7DFqADVmADVmADVh/DVl/DVl+AECADlp/DVmADlmADVl/DFmADVmADFeAGk2ADlmADlqADlqADVh/DVqAAFVxDVl/DVeADlp+DlqADlqADll/AFWAAGCADFp/DFl/AGZmDVl/Dld9DV55DVmADVmADVl/DVh/DVl/DVmADFmADVl/DVl/DVt9Dll/DVmADViADll/DlmADFl9DVmADFiADVl/////pwlF4gAAAGR0Uk5TAAIwZA3ohyD4qjwBzF/nlwvlKIybgimWc0z5HfYqoHdQ+qbpDENLA1T7OCvDTjlY/P7HwU0Eqopc/aTqLAqESqiFYAmjJkeAXoEGCLmPBfc1E8jktdvRxrjzyzuphmLPzj/wQC8LztMAAAABYktHRACIBR1IAAAACXBIWXMAAABIAAAASABGyWs+AAABW0lEQVQ4y72TZ1vCMBCAD9lTUBEFVEAUwQlO6kBxFVcVcLFc9/9/g9c0lTYtX70PbXLv+7SXXALwb+EYE8IhCE4UwmnmLrcouF0mwYOW8Bi512cVfF6D4Eeb8A95AG0joPNgyF4IBbkQ1jORcbMR1ng0pq9sAibV95RecizKhLjOp2mSQJyB2SRPxVWeSnM+x+qZX6BnJqvl0ima5LTxIvH8EjVluUDJlaKWzQGUOF8lvlbMABTWN8jY3GLpcgkqfzy6jZjdAdjd2yfjoMpABST1dXgEcCyd0ChZI+P0jIw6MyRWo8rPLy7rrAVX9JfcNRlyVauygZi4gdu7+wcmoEKVPqbJeGoiNtR9atEn2s+0zhfexnazjPj69o7YYjsl48iQtV51RvEO71Z3lNDV+92z573hiVPsuGI4c307oW84k/mIlUfyxmM9sAoD8837EPmncPe+voX44eAXvM/afnTm3m8AAAAldEVYdGRhdGU6Y3JlYXRlADIwMTQtMTItMTBUMTE6Mjc6MzEtMDU6MDCD+78IAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE0LTEyLTEwVDExOjI3OjI3LTA1OjAwXdwyEAAAAABJRU5ErkJggg=="><style>.sf-hidden{display:none!important}</style><link rel=canonical href=https://wiki.alpinelinux.org/wiki/Configure_a_Wireguard_interface_(wg)><meta http-equiv=content-security-policy content="default-src 'none'; font-src 'self' data:; img-src 'self' data:; style-src 'unsafe-inline'; media-src 'self' data:; script-src 'unsafe-inline' data:; object-src 'self' data:; frame-src 'self' data:;"><style>img[src="data:,"],source[src="data:,"]{display:none!important}</style></head>
<body class="skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Configure_a_Wireguard_interface_wg rootpage-Configure_a_Wireguard_interface_wg skin-vector-2022 action-view vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-language-alert-in-sidebar-disabled vector-feature-sticky-header-disabled vector-feature-sticky-header-edit-disabled vector-feature-table-of-contents-disabled vector-feature-visual-enhancement-next-disabled uls-dialog-sticky-hide vector-toc-not-collapsed vector-below-page-title"><div class=mw-page-container>
<span id=top-page></span>
<a class=mw-jump-link href=#content>Jump to content</a>
<div class=mw-page-container-inner>
<input type=checkbox id=mw-sidebar-checkbox class="mw-checkbox-hack-checkbox sf-hidden">
<header class=mw-header>
<div class=mw-header-aside>
<label id=mw-sidebar-button class="mw-checkbox-hack-button mw-ui-icon mw-ui-button mw-ui-quiet mw-ui-icon-element" for=mw-sidebar-checkbox role=button aria-controls=mw-panel data-event-name=ui.sidebar tabindex=0 title="Main menu" aria-expanded=false>
<span>Toggle sidebar</span>
</label>
<a href=https://wiki.alpinelinux.org/wiki/Main_Page class=mw-logo>
<span class=mw-logo-container>
<strong class=mw-logo-wordmark>Alpine Linux</strong>
</span>
</a>
</div>
<div class=mw-header-content>
<div id=p-search role=search class="vector-search-box-vue vector-search-box-collapses vector-search-box-show-thumbnail vector-search-box-auto-expand-width vector-search-box">
<a href=https://wiki.alpinelinux.org/wiki/Special:Search title="Search Alpine Linux [⌃⌥f]" accesskey=f class="mw-ui-button mw-ui-quiet mw-ui-icon mw-ui-icon-element mw-ui-icon-wikimedia-search search-toggle sf-hidden">
</a>
<div>
<form action=/w/index.php id=searchform class=vector-search-box-form>
<div id=simpleSearch class=vector-search-box-inner data-search-loc=header-moved>
<input class=vector-search-box-input type=search name=search placeholder="Search Alpine Linux" aria-label="Search Alpine Linux" autocapitalize=sentences title="Search Alpine Linux [⌃⌥f]" accesskey=f id=searchInput autocomplete=off value>
<input id=mw-searchButton class="searchButton mw-fallbackSearchButton" type=submit name=fulltext title="Search the pages for this text" value=Search>
<input id=searchButton class=searchButton type=submit name=go title="Go to a page with this exact name if it exists" value=Go>
</div>
</form>
</div>
</div>
<nav class=vector-user-links aria-label="Personal tools" role=navigation>
<div id=p-vector-user-menu-overflow class="vector-menu mw-portlet mw-portlet-vector-user-menu-overflow vector-user-menu-overflow">
<div class=vector-menu-content>
<ul class=vector-menu-content-list><li id=pt-createaccount-2 class="user-links-collapsible-item mw-list-item"><a href="https://wiki.alpinelinux.org/w/index.php?title=Special:CreateAccount&amp;returnto=Configure+a+Wireguard+interface+%28wg%29" title="You are encouraged to create an account and log in; however, it is not mandatory"><span>Create account</span></a></ul>
</div>
</div>
<div id=p-personal class="vector-menu mw-portlet mw-portlet-personal vector-user-menu vector-user-menu-logged-out vector-menu-dropdown" title="More options">
<input type=checkbox id=p-personal-checkbox role=button aria-haspopup=true data-event-name=ui.dropdown-p-personal class=vector-menu-checkbox>
<label id=p-personal-label for=p-personal-checkbox class="vector-menu-heading mw-ui-button mw-ui-quiet mw-ui-icon mw-ui-icon-element mw-ui-icon-ellipsis mw-ui-icon-wikimedia-ellipsis">
<span class=vector-menu-heading-label>Personal tools</span>
</label>
<div class=vector-menu-content>
<div class=vector-user-menu-create-account><a href="https://wiki.alpinelinux.org/w/index.php?title=Special:CreateAccount&amp;returnto=Configure+a+Wireguard+interface+%28wg%29" class="vector-menu-content-item user-links-collapsible-item sf-hidden" title="You are encouraged to create an account and log in; however, it is not mandatory"> </a></div>
<div class=vector-user-menu-login><a href="https://wiki.alpinelinux.org/w/index.php?title=Special:UserLogin&amp;returnto=Configure+a+Wireguard+interface+%28wg%29" class="vector-menu-content-item vector-menu-content-item-login" title="You are encouraged to log in; however, it is not mandatory [⌃⌥o]" accesskey=o><span class="mw-ui-icon mw-ui-icon-logIn mw-ui-icon-wikimedia-logIn"></span> <span>Log in</span></a></div>
<ul class=vector-menu-content-list></ul>
</div>
</div>
</nav>
</div>
</header>
<div class=vector-sidebar-container>
<div id=mw-navigation>
<nav id=mw-panel class="mw-sidebar sf-hidden" aria-label=Site role=navigation>
</nav>
</div>
</div>
<div class=vector-sitenotice-container>
<div id=siteNotice></div>
</div>
<input type=checkbox id=vector-toc-collapsed-checkbox class="mw-checkbox-hack-checkbox sf-hidden">
<div class=mw-table-of-contents-container>
<div class="vector-sticky-toc-container mw-sticky-header-element">
<nav id=mw-panel-toc class=sidebar-toc role=navigation aria-labelledby=sidebar-toc-label data-event-name=ui.sidebar-toc>
<div id=sidebar-toc-label class=sidebar-toc-header>
<p class=sidebar-toc-title>
Contents
<button class="vector-toc-uncollapse-button sf-hidden">move to sidebar</button>
<button class=vector-toc-collapse-button>hide</button>
</p>
</div>
<ul class=sidebar-toc-contents id=mw-panel-toc-list>
<li id=toc-mw-content-text class="sidebar-toc-list-item sidebar-toc-level-1">
<a href=#top-page class=sidebar-toc-link>
<div class=sidebar-toc-text>Beginning</div>
</a>
</li>
<li id=toc-Bringing_up_an_interface_using_wg-tools class="sidebar-toc-list-item sidebar-toc-level-1 sidebar-toc-list-item-expanded">
<a class=sidebar-toc-link href=#Bringing_up_an_interface_using_wg-tools>
<div class=sidebar-toc-text>
<span class="sidebar-toc-numb sf-hidden">1</span>Bringing up an interface using wg-tools</div>
</a>
<ul id=toc-Bringing_up_an_interface_using_wg-tools-sublist class=sidebar-toc-list>
</ul>
</li>
<li id=toc-Bringing_up_an_interface_using_ifupdown-ng class="sidebar-toc-list-item sidebar-toc-level-1 sidebar-toc-list-item-expanded sidebar-toc-list-item-active">
<a class=sidebar-toc-link href=#Bringing_up_an_interface_using_ifupdown-ng>
<div class=sidebar-toc-text>
<span class="sidebar-toc-numb sf-hidden">2</span>Bringing up an interface using ifupdown-ng</div>
</a>
<ul id=toc-Bringing_up_an_interface_using_ifupdown-ng-sublist class=sidebar-toc-list>
</ul>
</li>
<li id=toc-Enable_IP_Forwarding class="sidebar-toc-list-item sidebar-toc-level-1 sidebar-toc-list-item-expanded">
<a class=sidebar-toc-link href=#Enable_IP_Forwarding>
<div class=sidebar-toc-text>
<span class="sidebar-toc-numb sf-hidden">3</span>Enable IP Forwarding</div>
</a>
<ul id=toc-Enable_IP_Forwarding-sublist class=sidebar-toc-list>
</ul>
</li>
<li id=toc-Running_with_modloop class="sidebar-toc-list-item sidebar-toc-level-1 sidebar-toc-list-item-expanded">
<a class=sidebar-toc-link href=#Running_with_modloop>
<div class=sidebar-toc-text>
<span class="sidebar-toc-numb sf-hidden">4</span>Running with modloop</div>
</a>
<ul id=toc-Running_with_modloop-sublist class=sidebar-toc-list>
</ul>
</li>
</ul>
</nav>
</div>
</div>
<div class=mw-content-container>
<main id=content class=mw-body role=main>
<a id=top></a>
<header class=mw-body-header>
<label id=vector-toc-collapsed-button class="mw-ui-button mw-ui-quiet mw-ui-icon mw-ui-icon-element mw-ui-icon-wikimedia-listBullet mw-checkbox-hack-button sf-hidden" for=vector-toc-collapsed-checkbox role=button aria-controls=toc-toggle-list data-event-name=vector.toc-toggle-list tabindex=0 title="Table of Contents" aria-expanded=false>
Toggle the table of contents
</label>
<h1 id=firstHeading class="firstHeading mw-first-heading"><span class=mw-page-title-main>Configure a Wireguard interface (wg)</span></h1>
</header>
<nav class=vector-article-toolbar aria-label=Tools role=navigation>
<div class=mw-article-toolbar-container>
<div id=left-navigation>
<div id=p-associated-pages class="vector-menu mw-portlet mw-portlet-associated-pages vector-menu-tabs">
<div class=vector-menu-content>
<ul class=vector-menu-content-list><li id=ca-nstab-main class="selected mw-list-item"><a href=https://wiki.alpinelinux.org/wiki/Configure_a_Wireguard_interface_(wg) title="View the content page [⌃⌥c]" accesskey=c><span>Page</span></a><li id=ca-talk class=mw-list-item><a href=https://wiki.alpinelinux.org/wiki/Talk:Configure_a_Wireguard_interface_(wg) rel=discussion title="Discussion about the content page [⌃⌥t]" accesskey=t><span>Discussion</span></a></ul>
</div>
</div>
<div id=p-variants class="vector-menu mw-portlet mw-portlet-variants emptyPortlet vector-menu-dropdown sf-hidden">
</div>
</div>
<div id=right-navigation class=vector-collapsible>
<div id=p-views class="vector-menu mw-portlet mw-portlet-views vector-menu-tabs">
<div class=vector-menu-content>
<ul class=vector-menu-content-list><li id=ca-view class="selected mw-list-item"><a href=https://wiki.alpinelinux.org/wiki/Configure_a_Wireguard_interface_(wg)><span>Read</span></a><li id=ca-viewsource class=mw-list-item><a href="https://wiki.alpinelinux.org/w/index.php?title=Configure_a_Wireguard_interface_(wg)&amp;action=edit" title="This page is protected.
You can view its source [⌃⌥e]" accesskey=e><span>View source</span></a><li id=ca-history class=mw-list-item><a href="https://wiki.alpinelinux.org/w/index.php?title=Configure_a_Wireguard_interface_(wg)&amp;action=history" title="Past revisions of this page [⌃⌥h]" accesskey=h><span>View history</span></a></ul>
</div>
</div>
<div id=p-cactions class="vector-menu mw-portlet mw-portlet-cactions emptyPortlet vector-menu-dropdown vector-has-collapsible-items sf-hidden" title="More options">
</div>
</div>
</div>
</nav>
<div id=bodyContent class=vector-body data-mw-ve-target-container>
<div class=mw-body-subheader>
<div class=mw-indicators>
</div>
<div id=siteSub class="noprint sf-hidden">From Alpine Linux</div>
</div>
<div id=mw-content-text class="mw-body-content mw-content-ltr" dir=ltr lang=en><div class=mw-parser-output><table style="clear:left;margin-bottom:.5em;float:left;padding:.5em 1.4em .8em 0;background:none;width:auto" cellspacing=0 cellpadding=0>
<tbody><tr>
<td><mw:tocplace></mw:tocplace>
</table>
<p>WireGuard is a very promising VPN technology available in the community repository since Alpine 3.10.
<p>There are several ways to install and configure an interface.
<p>In order to load the WireGuard kernel module, you need a compatible kernel:
</p>
<ul><li>linux-lts</li>
<li>linux-virt</ul>
<h2><span class=mw-headline id=Bringing_up_an_interface_using_wg-tools>Bringing up an interface using wg-tools</span></h2>
<p>The most straightforward method, and the one recommended in WireGuard documentation, is to use <code>wg-quick</code>.
<p>Install wireguard-tools
</p>
<pre>apk add wireguard-tools
</pre>
<p>Reboot and then load the module
</p>
<pre>modprobe wireguard
</pre>
<p>Add it to <code>/etc/modules</code> to automatically load it on boot.
<p>Then, we need to create a private and a public key:
</p>
<pre>wg genkey | tee privatekey | wg pubkey &gt; publickey
</pre>
<p>Then, we create a new config file <code>/etc/wireguard/wg0.conf</code> using those keys:
</p>
<pre>[Interface]
Address = 10.123.0.1/24
ListenPort = 45340
PrivateKey = SG1nXk2+kAAKnMkL5aX3NSFPaGjf9SQI/wWwFj9l9U4= # the key from the previously generated privatekey file
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;iptables -A FORWARD -o %i -j ACCEPT
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE;iptables -D FORWARD -o %i -j ACCEPT
</pre>
<p>The PostUp and PostDown steps are there to ensure the interface wg0 will accept and forward traffic to eth0. The postrouting and forward to %i is not required, but it will enable "VPN mode" where users can access the internet via this server if desired.
Note that this requires <code>iptables</code> installed and enabled: <code>apk add iptables &amp;&amp; rc-update add iptables</code>.
Reference <a rel=nofollow class="external text" href=https://github.com/pirate/wireguard-docs#user-content-config-reference>this WireGuard documentation</a> for information on adding peers to the config file.
<p>To bring up the new interface we use:
</p>
<pre>wg-quick up wg0
</pre>
<p>To take it down, we can use <code>wg-quick down wg0</code> which will clean up the interface and remove the iptables rules.
Note: If running in a Docker container, you will need to run with <code>--cap-add=NET_ADMIN</code> to modify your interfaces.
</p>
<h2><span class=mw-headline id=Bringing_up_an_interface_using_ifupdown-ng>Bringing up an interface using ifupdown-ng</span></h2>
<p>The official documents from WireGuard show examples of how to set up an interface with the use of wg-quick.
In this how-to, we are not going to use that utility. We'll use the plain wg command and <a rel=nofollow class="external text" href=https://github.com/ifupdown-ng/ifupdown-ng/blob/master/doc/interfaces-wireguard.scd>ifupdown-ng</a>.
</p>
<pre>apk add wireguard-tools-wg
</pre>
<p>Now that all the tools are installed, you can setup the interface.
The setup of your interface config is out of the scope of this document. You should consult the <a rel=nofollow class="external text" href=https://git.zx2c4.com/WireGuard/about/src/tools/man/wg.8>manual page of wg</a>.
<p>After you have finished setting up your wgX interface config, you can add it to your <code>/etc/network/interfaces</code>:
</p>
<pre>auto wg0
iface wg0 inet static
requires eth0
use wireguard
address 192.168.42.1
post-up iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;iptables -A FORWARD -o wg0 -j ACCEPT
post-down iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE;iptables -D FORWARD -o wg0 -j ACCEPT
</pre>
<p>This config will automatically:
</p>
<ul><li>bring the WireGuard interface up after the eth0 interface</li>
<li>assign a config to this interface (which you have previously created)</li>
<li>setup the interface address and netmask</li>
<li>add the route once the interface is up</li>
<li>remove the interface when it goes down</li>
<li>enable traffic forwarding (the <code>post-up</code> and <code>post-down</code> lines; requires <code>iptables</code>) (note that this is not required unless you want peers to be able to access external resources like the internet)</ul>
<div style="padding:0.25em;margin:0.50em 0;background-color:#DDDDFF;border:2px solid #BBBBFF"><strong> Note: </strong><span class=Alp-Note>If you are using the same config (/etc/wireguard/wg0.conf) from a <code>wg-quick</code> setup, you must comment out the <code>Address</code> line in the <code>[Interface]</code> section. Otherwise, the interface will not come up.</span></div>
<p>To start and stop the interface, you execute:
</p>
<pre>ifup wg0
ifdown wg0
</pre>
<p>If your interface config is not stored under <code>/etc/wireguard/</code> you need to specify a <code>wireguard-config-path</code> as well.
</p>
<h2><span class=mw-headline id=Enable_IP_Forwarding>Enable IP Forwarding</span></h2>
<p>If you intend for peers to be able to access external resources (including the internet), you will need to enable forwarding.
Edit the file <code>/etc/sysctl.conf</code> (or a <code>.conf</code> file under <code>/etc/sysctl.d/</code>) and add the following line.
</p>
<pre>net.ipv4.ip_forward = 1
</pre>
<p>Then either reboot or run <code>sysctl -p /etc/sysctl.conf</code> to reload the settings.
To ensure forwarding is turned on, run <code>sysctl -a | grep ip_forward</code> and ensure <code>net.ipv4.ip_forward</code> is set to <code>1</code>.
To make the change permanent across reboots, you may need to enable the <code>sysctl</code> service: <code>rc-update add sysctl</code>.
<p><br>
</p>
<h2><span class=mw-headline id=Running_with_modloop>Running with modloop</span></h2>
<p>If you are running from a RAM disk, you can't modify the modloop.
<p>You can get around it by unpacking the modloop, mounting the unpacked modules folder, then installing WireGuard.
</p>
<pre>#!/bin/sh
apk add squashfs-tools # install squashfs tools to unpack modloop
unsquashfs -d /root/squash /lib/modloop-lts # unpack modloop to root dir
umount /.modloop # unmount existing modloop
mount /root/squash/ /.modloop/ # mount unpacked modloop
apk del wireguard-lts # uninstall previous WireGuard install
apk add wireguard-lts
apk add wireguard-tools
</pre>
<p>You can repack the squash filesystem or put this script in the /etc/local.d/ path so it runs at boot-up.
</p>
</div>
<div class="printfooter sf-hidden" data-nosnippet>Retrieved from ""</div></div>
<div id=catlinks class=catlinks data-mw=interface><div id=mw-normal-catlinks class=mw-normal-catlinks><a href=https://wiki.alpinelinux.org/wiki/Special:Categories title=Special:Categories>Category</a>: <ul><li><a href=https://wiki.alpinelinux.org/wiki/Category:Networking title=Category:Networking>Networking</a></ul></div></div>
</div>
</main>
</div>
<div class=mw-footer-container>
<footer id=footer class=mw-footer role=contentinfo>
<ul id=footer-info>
<li id=footer-info-lastmod> This page was last edited on 12 August 2022, at 20:58.</li>
<li id=footer-info-copyright><div align=right><div id=footer-inner>
<p><a href=https://wiki.alpinelinux.org/wiki/Privacy_Policy#Copyright>© Copyright 2008-2021 Alpine Linux Development Team</a>
all rights reserved </p></div></div></li>
</ul>
<ul id=footer-places>
<li id=footer-places-privacy><a href=https://wiki.alpinelinux.org/wiki/Alpine_Linux:Privacy_policy>Privacy policy</a></li>
<li id=footer-places-about><a href=https://wiki.alpinelinux.org/wiki/Alpine_Linux:About>About</a></li>
<li id=footer-places-disclaimer><a href=https://wiki.alpinelinux.org/wiki/Alpine_Linux:General_disclaimer>Disclaimers</a></li>
</ul>
<ul id=footer-icons class=noprint>
<li id=footer-poweredbyico><a href=https://www.mediawiki.org/><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAAAfCAYAAABjyArgAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAOFklEQVRo3u2aeVRUV57HP6+WVxsUFIVUQBRsBbeMQZM0RmPGgEmgCd2azkwcTZsxyxCMS/poEve4TCcdiR0zxy1R1OMcB43RZIiCxhhjNMucKCrBqFEhIAgFFlBQQK3vzh8M1U0Egll6c37n3HPqvXfv797f9/7ub7slAQghpOLi4nkGg+FhWZZtKpVKw98hCSF+1H7fpkAg4HW73Ve9Xu/6kSNH/heAJISQSkpKdsfHxz8YEhKi+6kmv5movr7eWVlZmZuUlDRXKioqmj9o0KBlvQH3b0H7/lrIbrc3lpeXT1HJsvxrk8mkE0LQ+6Z0fm5tgI9/j/C19tzvB7S/5MZ+nxYVFRUuy/KzKr1eH3Wjk0qf7kPavx7R0tgu/EfrobwYzuS1T+C6CmdyoO7THw3gv1T7IaTT6WwalUqluWFGX51CqrmAqvwsyrhJSOVnQQbp/IcQMQjp3H+CqhUhh0HkmJvWXAghZE0gEPjuBV+7hnT1CsJ2C9iika45wAs0NKLatQoiIwA1+N1Ih34HEZEgA8017bxbriAFHAhTIqiNXU7R1NTEG2+8AYDNZiMzMxOLxfJnBWTfvn0YDAZSU1MBaG5uZtWqVaxcufJ7bawQgt5pb30Dqj/8AWQQfaPAUQUdPvFaAygBhM2G5KoBvYQwCRBAXSmqY78FpQ5kUEa9DipDl1M0NDSQm5vL2rVruXTpEuPGjePzzz/HZDL92QC+cOECZrOZlJQUADweD0eOHPneJyYI8HcxEH36IAJq1B4/VNmRrnwDESZE/75IkhGaWsECNLUiZCt4Q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3bWLduHcOGDWPnzp04nU4WL16MoiiMGDGCt99+m8TERNRqNXq9PljblWWZQYMGsX//fsLCwoLyZmRkYDAYSE9PD9YszGYzmZmZwT6hoaFoNBp0Oh1Dhw4lPDyc3NxcNm3aFIxGuou5FUVBOnr0aNVtt90W09NOVJfU8NmaDzHIgr4jomk8eRFZ+JDx479YRkiEAZPVgKqyCh0eTLF90OJDH25CHRmG9kopqAO0/W41IjTsprlIPX78+LluC+5/+j4i3sIDr/wKvVmHSqPm47nVeJxNCASavtEoBgmP8KOLshEItOERagQCqV8cmtn/htfjQVXvQNF1Xbv4e6VAIICqo1rU02WfbJIxRhhRadpTVn1MH7xo0f+sLwPnT27P9tDgN4cRvngGfksEXjQoUVEdBg8lOga08k92i/vX2BRFQeN2u703elT63B5P5PBo4lKGoNKqCU0eRvP/nCUq7S50g+ORX5yJ678PI9029G/pgvJH5+nz+TyahoaGGiD+RiaOu2dgp+9xU8dz1WzEmpbc3t+oJ+RfMm7qfwIpikJTU1OlOiUlRQoJCUkJDw+Xvy8zlUZN2PD+XWW/N80/ebooVdaWlZXNUBcUFBQlJSX1k2V5cEREhI7/px+0uUIIioqKas+fP7967ty5u4I6t3r16l+bzeZsk8kU1VEvvZk18PuQx+MRLpersqGh4d8XLlz4GcD/ApR21lbjsXIlAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIwLTExLTIzVDAxOjU2OjU0KzAwOjAwXp3WLgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMC0xMS0yM1QwMTo1Njo1NCswMDowMC/AbpIAAAAASUVORK5CYII=" alt="Powered by MediaWiki" srcset loading=lazy sizes width=88 height=31></a></li>
</ul>
</footer>
</div>
</div>
</div>
<div id=p-namespaces style=display:none></div>