Operation of the network can be handle with init scripts;
Choose wireless or net as connection to outside world and configure /etc/rc.conf to run at startup, example connecting using wireless interface;
# # /etc/rc.conf: system configuration # FONT=default KEYMAP=dvorak TIMEZONE="Europe/Lisbon" HOSTNAME=c9 SYSLOG=sysklogd SERVICES=(lo iptables wlan crond) # End of file
If is first boot after install configure iptables and one of above described scripts then proceed to update system.
This example will use Chaos Computer Club server, edit /etc/resolv.conf and make it immutable;
# /etc/resolv.conf.head can replace this line nameserver 213.73.91.35 # /etc/resolv.conf.tail can replace this line
# chattr +i /etc/resolv.conf
Current example of /etc/rc.d/net;
Address: 192.168.0.1 11000000.10101000.00000000 .00000001 Netmask: 255.255.255.0 = 24 11111111.11111111.11111111 .00000000 Wildcard: 0.0.0.255 00000000.00000000.00000000 .11111111 => Network: 192.168.0.0/24 11000000.10101000.00000000 .00000000 (Class C) Broadcast: 192.168.0.255 11000000.10101000.00000000 .11111111 HostMin: 192.168.0.1 11000000.10101000.00000000 .00000001 HostMax: 192.168.0.254 11000000.10101000.00000000 .11111110 Hosts/Net: 254 (Private Internet)
Other IP class that can used for private network;
Address: 10.0.0.1 00001010.00000000.00000000 .00000001 Netmask: 255.255.255.0 = 24 11111111.11111111.11111111 .00000000 Wildcard: 0.0.0.255 00000000.00000000.00000000 .11111111 => Network: 10.0.0.0/24 00001010.00000000.00000000 .00000000 (Class A) Broadcast: 10.0.0.255 00001010.00000000.00000000 .11111111 HostMin: 10.0.0.1 00001010.00000000.00000000 .00000001 HostMax: 10.0.0.254 00001010.00000000.00000000 .11111110 Hosts/Net: 254 (Private Internet)
Manual configuring like net script;
# DEV=enp8s0 # ADDR=192.168.1.9 # MASK=24 # GW=192.168.1.254
# ip addr flush dev ${DEV} # ip route flush dev ${DEV} # ip addr add ${ADDR}/${MASK} dev ${DEV} broadcast + # ip link set ${DEV} up # ip route add default via ${GW}
For more information about iptables read arch wiki. You can use /etc/iptables/rules.v4 or /etc/iptables/iptables-lan.sh as a template, replace interfaces by correct ones. This configuration file is used at boot time by iptables-restore command, if you use a script or change the rules of running system you can use iptables-save command to save configuration to a file.
# mkdir /etc/iptables # cp c9-doc/core/conf/iptables/rules.v4 /etc/iptables/ # cp c9-doc/core/conf/rc.d/iptables /etc/rc.d/ # chmod +x /etc/rc.d/iptables
Adjust rules.v4 to your needs, then;
# sh /etc/rc.d/iptables start
Copy init script, edit if you dont like to let drop when you call stop.
Re-configure your rc.conf and add iptables before (w)lan is up;
SERVICES=(lo iptables net crond)
There is more information on Wiki Wifi Start Scripts and see /etc/rc.d/wlan. Manual or first time configuration;
# ip link
# iwlist wlp2s0 scan
# iwconfig wlp2s0 essid NAME key s:ABCDE12345
Configure wpa supplicant edit;
# vim /etc/wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant update_config=1 fast_reauth=1 ap_scan=1
# wpa_passphrase <ssid> <password> >> /etc/wpa_supplicant.conf
Now start wpa_supplicant with:
# wpa_supplicant -B -i wlp2s0 -c /etc/wpa_supplicant.conf Successfully initialized wpa_supplicant
Use /etc/rc.d/wlan init script to auto load wpa configuration and dhcp client.
# wpa_cli > status
> add_network 3
> set_network 3 ssid "Crux-Network" OK
> set_network 3 psk "uber-secret-pass" OK
> enable_network 3 OK
> list_networks
> select_network 3
> save_configCore OS Index
This is part of the c9-doc Manual. Copyright (C) 2017 c9 team. See the file Gnu Free Documentation License for copying conditions.