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. Iptables can be setup at boot with /etc/rc.d/iptables init script, change iptables.sh with your needs and run to save rules in /etc/iptables/net.v4 file.
Init script "start" option loads set of rules from file /etc/iptables/rules.v4, "open" option allows everything to outside and blocks everything from outside, "stop" will block and log everything.
Setup init script and rules ;
# mkdir /etc/iptables
# cp core/conf/iptables/net.v4 /etc/iptables/
# cp core/conf/rc.d/iptables /etc/rc.d/
# chmod +x /etc/rc.d/iptables
Change /etc/rc.conf and add iptables;
SERVICES=(iptables lo net crond)
Adjust iptables.sh with your network configuration then run it;
# bash core/scripts/iptables.sh
See current rules and packets;
# iptables -L -n -v | less
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_config
Core 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.