version=pmwiki-2.2.130 ordered=1 urlencoded=1 agent=w3m/0.5.3+git20210102 author=jrmu charset=UTF-8 csum= ctime=1597203404 host=38.87.162.8 name=Openbsd.Staticnet rev=7 targets=Openbsd.Ping,Openbsd.Netcat,Openbsd.Traceroute text=(:redirect hostnameif.static:)%0a(:title Configuring Static Networking:)%0a%0aMost computer users don't have to deal with networking because they use DHCP, where the router automatically figures out and assign IP addresses to each device. However, if you are running a server, it's important to configure static networking so that your IP addresses don't change in an unpredictable manner. Static networking is preferred to get reliable IPv4 and IPv6 networking.%0a%0aIf you chose DHCP when first installing OpenBSD, you will need to follow the steps below to configure the networking manually.%0a%0a'''WARNING''': Make sure you warn any connected users before attempting to change your networking. Any mistakes here can cause all your users to get disconnected. If you are worried about making mistakes, you should practice first on a separate server. Please also be prepared to use VNC in case ssh stops working.%0a%0a!! hostname.if%0a%0aOpenBSD requires one hostname.if per networking interface, where the letters 'if' are replaced with an abbreviation followed by a device number. For example, if you have a virtio networking interface, it will be abbreviated by vio, so you will need an /etc/hostname.vio0 file.%0a%0aInside /etc/hostname.if (where you replace if with your device), you should put something similar to the following lines:%0a%0a[@%0ainet 192.168.1.2 255.255.255.0%0ainet alias 192.168.1.3 255.255.255.0%0ainet6 2001:0db8:0000:0000:0000:0000:0000:0000 48%0ainet6 alias 2001:0db8:0000:0000:9b1d:3511:387e:143a 48%0ainet6 alias 2001:0db8:0000:0000:1465:fed1:8daf:66ff 48%0ainet6 alias 2001:0db8:0000:0000:11b4:4a36:2941:d6bd 48%0ainet6 alias 2001:0db8:0000:0000:ad2c:5b99:2b1a:89d1 48%0ainet6 alias 2001:0db8:0000:0000:921d:28ad:4729:8d93 48%0a@]%0a%0aNote: Do '''not''' use those exact IP addresses. Use the real IP addresses you were assigned by your ISP.%0a%0aLet's look at the first two lines:%0a%0a[@%0ainet 192.168.1.2 255.255.255.0%0ainet alias 192.168.1.3 255.255.255.0%0a@]%0a%0aThe first line will set the device to use the static IP 192.168.1.2 with subnet mask 255.255.255.0. The second line will allow the device to use a second static IP, 192.168.1.3. It will be aliased to the first and have the same subnet mask.%0a%0aIt makes sense to have an aliased IP address when two or more IP addresses share the exact same networking interface. You will see this being done if you have one normal IPv4 address and a DDoS filtered IPv4 address. Both of them actually share the same networking interface, so the unfiltered IPv4 address is actually an alias of the filtered one.%0a%0aLet's look at lines 3 and 4:%0a%0a[@%0ainet6 2001:0db8:0000:0000:0000:0000:0000:0000 48%0ainet6 alias 2001:0db8:0000:0000:9b1d:3511:387e:143a 48%0a@]%0a%0aThe first line sets the device to use the static IPv6 address 2001:0db8:: with a /48 subnet, and the second one creates another IPv6 address 2001:0db8:0000:0000:9b1d:3511:387e:143a with a /48 subnet, aliased to the first IPv6 address. Each time you need a new IPv6 address, just add a new aliased IPv6 address. In this way, you can create dozens of unique IPv6 addresses so that each user on a shell account or bouncer can get a unique IPv6 address.%0a%0aIn the file /etc/mygate, you specify the default gateway:%0a%0a[@%0a192.168.1.1%0a2001:0db8:0000:0000::1%0a@]%0a%0aThe default gateway is the router that your server is connected to. This is where all the IP packets from your server will immediately forward its packets to. The default gateway will be provided by your ISP.%0a%0aTo restart networking, run:%0a%0a[@%0a$ doas sh /etc/netstart%0a@]%0a%0aIf this doesn't properly reset the networking, you can do the following:%0a%0a'''WARNING''': This will definitely disconnect all network connections.%0a%0a[@%0a$ doas ifconfig if0 down%0a$ doas route flush%0a$ doas sh /etc/netstart%0a@]%0a%0aNote: Make sure to replace if0 with your real device.%0a%0a!! ifconfig%0a%0aYou can add new IPv4 addresses on the fly, without rebooting, by using ifconfig:%0a%0a[@%0a$ doas ifconfig if0 alias 192.168.1.3 255.255.255.0%0a@]%0a%0aFor IPv6:%0a%0a[@%0a$ doas ifconfig if0 inet6 2001:0db8::/48%0a@]%0a%0aTo delete an IPv4 address:%0a%0a[@%0a$ doas ifconfig if0 192.168.1.3 delete%0a@]%0a%0aTo delete the IPv6 address:%0a%0a[@%0a$ doas ifconfig if0 inet6 2001:0db8::/48 delete%0a@]%0a%0aNote: replace if0 with your specific interface, and replace the IP addresses and subnet masks.%0a%0aTo test if an IP address is working, you can use [[openbsd/ping|ping]], [[openbsd/netcat|netcat]], and [[openbsd/traceroute|traceroute]].%0a time=1626112120 title=Configuring Static Networking author:1626112120=jrmu diff:1626112120:1609088216:=1d0%0a%3c (:redirect hostnameif.static:)%0a104c103%0a%3c To test if an IP address is working, you can use [[openbsd/ping|ping]], [[openbsd/netcat|netcat]], and [[openbsd/traceroute|traceroute]].%0a---%0a> To test if an IP address is working, you can use [[openbsd/ping|ping]], [[openbsd/netcat|netcat]], and [[openbsd/traceroute|traceroute]].%0a\ No newline at end of file%0a host:1626112120=38.87.162.8 author:1609088216=jrmu diff:1609088216:1602296247:=80c80%0a%3c $ doas ifconfig if0 alias 192.168.1.3 255.255.255.0%0a---%0a> $ doas ifconfig if0 192.168.1.3 255.255.255.0%0a host:1609088216=198.251.81.119 author:1602296247=jrmu diff:1602296247:1597223140:=86c86%0a%3c $ doas ifconfig if0 inet6 2001:0db8::/48%0a---%0a> $ doas ifconfig if0 inet6 2001:0db8::/64%0a98c98%0a%3c $ doas ifconfig if0 inet6 2001:0db8::/48 delete%0a---%0a> $ doas ifconfig if0 inet6 2001:0db8::/64 delete%0a host:1602296247=38.81.163.143 author:1597223140=jrmu diff:1597223140:1597223105:=103c103%0a%3c To test if an IP address is working, you can use [[openbsd/ping|ping]], [[openbsd/netcat|netcat]], and [[openbsd/traceroute|traceroute]].%0a\ No newline at end of file%0a---%0a> To test if an IPv6 address is working, you can use [[openbsd/ping|ping]], [[openbsd/netcat|netcat]], and [[openbsd/traceroute|traceroute]].%0a\ No newline at end of file%0a host:1597223140=38.81.163.143 author:1597223105=jrmu diff:1597223105:1597221508:=5,14c5,13%0a%3c If you chose DHCP when first installing OpenBSD, you will need to follow the steps below to configure the networking manually.%0a%3c %0a%3c '''WARNING''': Make sure you warn any connected users before attempting to change your networking. Any mistakes here can cause all your users to get disconnected. If you are worried about making mistakes, you should practice first on a separate server. Please also be prepared to use VNC in case ssh stops working.%0a%3c %0a%3c !! hostname.if%0a%3c %0a%3c OpenBSD requires one hostname.if per networking interface, where the letters 'if' are replaced with an abbreviation followed by a device number. For example, if you have a virtio networking interface, it will be abbreviated by vio, so you will need an /etc/hostname.vio0 file.%0a%3c %0a%3c Inside /etc/hostname.if (where you replace if with your device), you should put something similar to the following lines:%0a%3c %0a---%0a> If you chose DHCP when first installing OpenBSD, you will need to edit the networking configuration manually.%0a> %0a> OpenBSD requires one hostname.if per device, where the letters 'if' are replaced with an abbreviation followed by a device number. So, for example, an Atheros IEEE 802.11a/b/g/n wifi device is abbreviated by athn0, and will need an /etc/hostname.athn0 file.%0a> %0a> %0a> %0a> %0a> Replace if with your own device name. Inside /etc/hostname.if0, put:%0a> %0a26,27d24%0a%3c Note: Do '''not''' use those exact IP addresses. Use the real IP addresses you were assigned by your ISP.%0a%3c %0a30c27%0a%3c [@%0a---%0a> %3ccode>%0a33,34c30,31%0a%3c @]%0a%3c %0a---%0a> %3c/code>%0a> %0a37,38d33%0a%3c It makes sense to have an aliased IP address when two or more IP addresses share the exact same networking interface. You will see this being done if you have one normal IPv4 address and a DDoS filtered IPv4 address. Both of them actually share the same networking interface, so the unfiltered IPv4 address is actually an alias of the filtered one.%0a%3c %0a41c36%0a%3c [@%0a---%0a> %3ccode>%0a44,50c39,45%0a%3c @]%0a%3c %0a%3c The first line sets the device to use the static IPv6 address 2001:0db8:: with a /48 subnet, and the second one creates another IPv6 address 2001:0db8:0000:0000:9b1d:3511:387e:143a with a /48 subnet, aliased to the first IPv6 address. Each time you need a new IPv6 address, just add a new aliased IPv6 address. In this way, you can create dozens of unique IPv6 addresses so that each user on a shell account or bouncer can get a unique IPv6 address.%0a%3c %0a%3c In the file /etc/mygate, you specify the default gateway:%0a%3c %0a%3c [@%0a---%0a> %3c/code>%0a> %0a> The first one sets the device to use the static IPv6 address 2001:0db8:: with a /48 subnet, and the second one creates another IPv6 address 2001:0db8:0000:0000:9b1d:3511:387e:143a with a /48 subnet, aliased to the first IPv6 address. In this way, you can create dozens of unique IPv6 addresses so that each user on a shell account or bouncer can get a unique IPv6 address.%0a> %0a> You will also need to specify the default gateway in /etc/mygate:%0a> %0a> %3ccode>%0a53,59c48,52%0a%3c @]%0a%3c %0a%3c The default gateway is the router that your server is connected to. This is where all the IP packets from your server will immediately forward its packets to. The default gateway will be provided by your ISP.%0a%3c %0a%3c To restart networking, run:%0a%3c %0a%3c [@%0a---%0a> %3c/code>%0a> %0a> Sometimes, to restart networking, I will run:%0a> %0a> %3ccode>%0a61,85c54,62%0a%3c @]%0a%3c %0a%3c If this doesn't properly reset the networking, you can do the following:%0a%3c %0a%3c '''WARNING''': This will definitely disconnect all network connections.%0a%3c %0a%3c [@%0a%3c $ doas ifconfig if0 down%0a%3c $ doas route flush%0a%3c $ doas sh /etc/netstart%0a%3c @]%0a%3c %0a%3c Note: Make sure to replace if0 with your real device.%0a%3c %0a%3c !! ifconfig%0a%3c %0a%3c You can add new IPv4 addresses on the fly, without rebooting, by using ifconfig:%0a%3c %0a%3c [@%0a%3c $ doas ifconfig if0 192.168.1.3 255.255.255.0%0a%3c @]%0a%3c %0a%3c For IPv6:%0a%3c %0a%3c [@%0a---%0a> %3c/code>%0a> %0a> But this doesn't seem to properly reset the networking sometimes.%0a> %0a> Watch out! Iked, without the -6 flag, will block all IPv6 traffic.%0a> %0a> If you later decide you want to add a new ipv6 address, use ifconfig:%0a> %0a> %3ccode>%0a87,94c64,65%0a%3c @]%0a%3c %0a%3c To delete an IPv4 address:%0a%3c %0a%3c [@%0a%3c $ doas ifconfig if0 192.168.1.3 delete%0a%3c @]%0a%3c %0a---%0a> %3c/code>%0a> %0a97c68%0a%3c [@%0a---%0a> %3ccode>%0a99,103c70,86%0a%3c @]%0a%3c %0a%3c Note: replace if0 with your specific interface, and replace the IP addresses and subnet masks.%0a%3c %0a%3c To test if an IPv6 address is working, you can use [[openbsd/ping|ping]], [[openbsd/netcat|netcat]], and [[openbsd/traceroute|traceroute]].%0a\ No newline at end of file%0a---%0a> %3c/code>%0a> %0a> Replace if0 with your specific interface.%0a> %0a> ----%0a> %0a> To test if an IPv6 address is working, you can use netcat to connect to an IRC network that supports IPv6:%0a> %0a> %3ccode>%0a> $ nc -s 2001:0db8:: ipv6.ircnow.org 6667%0a> nick newnick%0a> user newuser * * :newuser%0a> PING :12345%0a> PONG :12345%0a> %3c/code>%0a> %0a> If that loads a message, then you configured the IPv6 address 2001:0db8:: correctly.%0a\ No newline at end of file%0a host:1597223105=38.81.163.143 author:1597221508=jrmu diff:1597221508:1597203404:=1,11c1,6%0a%3c (:title Configuring Static Networking:)%0a%3c %0a%3c Most computer users don't have to deal with networking because they use DHCP, where the router automatically figures out and assign IP addresses to each device. However, if you are running a server, it's important to configure static networking so that your IP addresses don't change in an unpredictable manner. Static networking is preferred to get reliable IPv4 and IPv6 networking.%0a%3c %0a%3c If you chose DHCP when first installing OpenBSD, you will need to edit the networking configuration manually.%0a%3c %0a%3c OpenBSD requires one hostname.if per device, where the letters 'if' are replaced with an abbreviation followed by a device number. So, for example, an Atheros IEEE 802.11a/b/g/n wifi device is abbreviated by athn0, and will need an /etc/hostname.athn0 file.%0a%3c %0a%3c %0a%3c %0a%3c %0a---%0a> %0a> %0a> If you chose DHCP when first installing the OS, you may want to edit the networking configuration manually (to switch to a static IP).%0a> %0a> Openbsd requires one hostname.if per device, where the letters 'if' are replaced with an abbreviation followed by a device number. So, for example, an Atheros IEEE 802.11a/b/g/n wifi device is abbreviated by athn0, and will need an /etc/hostname.athn0 file.%0a> %0a22a18,44%0a> inet6 alias 2001:0db8:0000:0000:c9bb:45f7:c494:1fc1 48%0a> inet6 alias 2001:0db8:0000:0000:5142:9b81:dec2:186c 48%0a> inet6 alias 2001:0db8:0000:0000:a118:dd85:a14f:72d7 48%0a> inet6 alias 2001:0db8:0000:0000:91f2:4943:de98:c9d5 48%0a> inet6 alias 2001:0db8:0000:0000:18a4:1ca3:5d31:2ddc 48%0a> inet6 alias 2001:0db8:0000:0000:31af:1656:16cf:611a 48%0a> inet6 alias 2001:0db8:0000:0000:8d27:5b44:3e75:4b86 48%0a> inet6 alias 2001:0db8:0000:0000:a259:79f6:fa54:a5e2 48%0a> inet6 alias 2001:0db8:0000:0000:59d8:f8ae:18a3:3644 48%0a> inet6 alias 2001:0db8:0000:0000:1dc7:c1c7:7b16:1151 48%0a> inet6 alias 2001:0db8:0000:0000:1c46:b131:e9de:edc1 48%0a> inet6 alias 2001:0db8:0000:0000:e72b:6165:b6fb:161f 48%0a> inet6 alias 2001:0db8:0000:0000:244c:47c2:f8fd:4bc2 48%0a> inet6 alias 2001:0db8:0000:0000:f664:e887:826d:64c5 48%0a> inet6 alias 2001:0db8:0000:0000:f8e7:1ca5:4852:9e78 48%0a> inet6 alias 2001:0db8:0000:0000:59e5:7568:ab7f:289f 48%0a> inet6 alias 2001:0db8:0000:0000:111e:6834:a1b1:64ff 48%0a> inet6 alias 2001:0db8:0000:0000:de32:1311:18d4:6f8b 48%0a> inet6 alias 2001:0db8:0000:0000:5714:1f81:156f:572b 48%0a> inet6 alias 2001:0db8:0000:0000:2589:ad14:872a:fa94 48%0a> inet6 alias 2001:0db8:0000:0000:5b15:e14f:812e:fa84 48%0a> inet6 alias 2001:0db8:0000:0000:5982:9c11:c2eb:c6ed 48%0a> inet6 alias 2001:0db8:0000:0000:abaf:88e4:69e1:f2a5 48%0a> inet6 alias 2001:0db8:0000:0000:a52b:5de1:ceba:b65a 48%0a> inet6 alias 2001:0db8:0000:0000:7e8b:f585:f2e7:66a1 48%0a> inet6 alias 2001:0db8:0000:0000:46ad:1add:cb77:154b 48%0a> inet6 alias 2001:0db8:0000:0000:b664:368a:d94b:3ce8 48%0a host:1597221508=38.81.163.143 author:1597203404=jrmu diff:1597203404:1597203404:=1,108d0%0a%3c %0a%3c %0a%3c If you chose DHCP when first installing the OS, you may want to edit the networking configuration manually (to switch to a static IP).%0a%3c %0a%3c Openbsd requires one hostname.if per device, where the letters 'if' are replaced with an abbreviation followed by a device number. So, for example, an Atheros IEEE 802.11a/b/g/n wifi device is abbreviated by athn0, and will need an /etc/hostname.athn0 file.%0a%3c %0a%3c Replace if with your own device name. Inside /etc/hostname.if0, put:%0a%3c %0a%3c [@%0a%3c inet 192.168.1.2 255.255.255.0%0a%3c inet alias 192.168.1.3 255.255.255.0%0a%3c inet6 2001:0db8:0000:0000:0000:0000:0000:0000 48%0a%3c inet6 alias 2001:0db8:0000:0000:9b1d:3511:387e:143a 48%0a%3c inet6 alias 2001:0db8:0000:0000:1465:fed1:8daf:66ff 48%0a%3c inet6 alias 2001:0db8:0000:0000:11b4:4a36:2941:d6bd 48%0a%3c inet6 alias 2001:0db8:0000:0000:ad2c:5b99:2b1a:89d1 48%0a%3c inet6 alias 2001:0db8:0000:0000:921d:28ad:4729:8d93 48%0a%3c inet6 alias 2001:0db8:0000:0000:c9bb:45f7:c494:1fc1 48%0a%3c inet6 alias 2001:0db8:0000:0000:5142:9b81:dec2:186c 48%0a%3c inet6 alias 2001:0db8:0000:0000:a118:dd85:a14f:72d7 48%0a%3c inet6 alias 2001:0db8:0000:0000:91f2:4943:de98:c9d5 48%0a%3c inet6 alias 2001:0db8:0000:0000:18a4:1ca3:5d31:2ddc 48%0a%3c inet6 alias 2001:0db8:0000:0000:31af:1656:16cf:611a 48%0a%3c inet6 alias 2001:0db8:0000:0000:8d27:5b44:3e75:4b86 48%0a%3c inet6 alias 2001:0db8:0000:0000:a259:79f6:fa54:a5e2 48%0a%3c inet6 alias 2001:0db8:0000:0000:59d8:f8ae:18a3:3644 48%0a%3c inet6 alias 2001:0db8:0000:0000:1dc7:c1c7:7b16:1151 48%0a%3c inet6 alias 2001:0db8:0000:0000:1c46:b131:e9de:edc1 48%0a%3c inet6 alias 2001:0db8:0000:0000:e72b:6165:b6fb:161f 48%0a%3c inet6 alias 2001:0db8:0000:0000:244c:47c2:f8fd:4bc2 48%0a%3c inet6 alias 2001:0db8:0000:0000:f664:e887:826d:64c5 48%0a%3c inet6 alias 2001:0db8:0000:0000:f8e7:1ca5:4852:9e78 48%0a%3c inet6 alias 2001:0db8:0000:0000:59e5:7568:ab7f:289f 48%0a%3c inet6 alias 2001:0db8:0000:0000:111e:6834:a1b1:64ff 48%0a%3c inet6 alias 2001:0db8:0000:0000:de32:1311:18d4:6f8b 48%0a%3c inet6 alias 2001:0db8:0000:0000:5714:1f81:156f:572b 48%0a%3c inet6 alias 2001:0db8:0000:0000:2589:ad14:872a:fa94 48%0a%3c inet6 alias 2001:0db8:0000:0000:5b15:e14f:812e:fa84 48%0a%3c inet6 alias 2001:0db8:0000:0000:5982:9c11:c2eb:c6ed 48%0a%3c inet6 alias 2001:0db8:0000:0000:abaf:88e4:69e1:f2a5 48%0a%3c inet6 alias 2001:0db8:0000:0000:a52b:5de1:ceba:b65a 48%0a%3c inet6 alias 2001:0db8:0000:0000:7e8b:f585:f2e7:66a1 48%0a%3c inet6 alias 2001:0db8:0000:0000:46ad:1add:cb77:154b 48%0a%3c inet6 alias 2001:0db8:0000:0000:b664:368a:d94b:3ce8 48%0a%3c @]%0a%3c %0a%3c Let's look at the first two lines:%0a%3c %0a%3c %3ccode>%0a%3c inet 192.168.1.2 255.255.255.0%0a%3c inet alias 192.168.1.3 255.255.255.0%0a%3c %3c/code>%0a%3c %0a%3c The first line will set the device to use the static IP 192.168.1.2 with subnet mask 255.255.255.0. The second line will allow the device to use a second static IP, 192.168.1.3. It will be aliased to the first and have the same subnet mask.%0a%3c %0a%3c Let's look at lines 3 and 4:%0a%3c %0a%3c %3ccode>%0a%3c inet6 2001:0db8:0000:0000:0000:0000:0000:0000 48%0a%3c inet6 alias 2001:0db8:0000:0000:9b1d:3511:387e:143a 48%0a%3c %3c/code>%0a%3c %0a%3c The first one sets the device to use the static IPv6 address 2001:0db8:: with a /48 subnet, and the second one creates another IPv6 address 2001:0db8:0000:0000:9b1d:3511:387e:143a with a /48 subnet, aliased to the first IPv6 address. In this way, you can create dozens of unique IPv6 addresses so that each user on a shell account or bouncer can get a unique IPv6 address.%0a%3c %0a%3c You will also need to specify the default gateway in /etc/mygate:%0a%3c %0a%3c %3ccode>%0a%3c 192.168.1.1%0a%3c 2001:0db8:0000:0000::1%0a%3c %3c/code>%0a%3c %0a%3c Sometimes, to restart networking, I will run:%0a%3c %0a%3c %3ccode>%0a%3c $ doas sh /etc/netstart%0a%3c %3c/code>%0a%3c %0a%3c But this doesn't seem to properly reset the networking sometimes.%0a%3c %0a%3c Watch out! Iked, without the -6 flag, will block all IPv6 traffic.%0a%3c %0a%3c If you later decide you want to add a new ipv6 address, use ifconfig:%0a%3c %0a%3c %3ccode>%0a%3c $ doas ifconfig if0 inet6 2001:0db8::/64%0a%3c %3c/code>%0a%3c %0a%3c To delete the IPv6 address:%0a%3c %0a%3c %3ccode>%0a%3c $ doas ifconfig if0 inet6 2001:0db8::/64 delete%0a%3c %3c/code>%0a%3c %0a%3c Replace if0 with your specific interface.%0a%3c %0a%3c ----%0a%3c %0a%3c To test if an IPv6 address is working, you can use netcat to connect to an IRC network that supports IPv6:%0a%3c %0a%3c %3ccode>%0a%3c $ nc -s 2001:0db8:: ipv6.ircnow.org 6667%0a%3c nick newnick%0a%3c user newuser * * :newuser%0a%3c PING :12345%0a%3c PONG :12345%0a%3c %3c/code>%0a%3c %0a%3c If that loads a message, then you configured the IPv6 address 2001:0db8:: correctly.%0a\ No newline at end of file%0a host:1597203404=38.81.163.143