A wired ethernet connection is the simplest to set up. All that is required is to give the interface an ip address and routing. This can be done statically or via dhcp. After getting the connection working, we'll create an s6-rc service definition so that on every boot the network will be properly configured at boot time.
The first step in setting up any network interface is making sure that
the interface is up. This is an example of the output of
ip link show
for an interface which is down.
2: eno1: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000
To power on this device we need to bring it up with the following command,
eno1 with the name of your actual device.
ip link set eno1 up
We then verify that the device is in fact up by running
ip link show
again and checking that the device is UP.
% ip link show eno1 2: eno1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000
Notice that instead of
<BROADCAST,MULTICAST> it now says
HitchHiker comes with the dhcpcd client for dynamic network configuration. This is the quickest way to configure a network interface.
# Get a dynamic ip address for the eth0 interface dhcpcd eth0
A Static ip address can be configured by once again using the
command, this time with it's
address subcommand. We're going to use
here to also set a correct network prefix and broadcast. Most users will
have a subnet mask of 255.255.255.0, with 24 leading 1-bits. Don't worry
if some of this is beyond your understanding, the commands should work
even if you don't understand every aspect.
# Set the ip address to 192.168.1.5 ip address add 192.168.1.5/24 broadcast + dev eth0
After setting the ip address, we next need to set up a route for this
device to reach the rest of the network. This is done once again with
ip command, this time using the
# Route goes through our router which has the internal ip 192.168.1.1 ip route add default via 192.168.1.1 eth0
There is one more step to configuring a network interface manually. If
we configure a dynamic address via dhcpcd, the client also configures
domain name resolution for us. When you configure an interface manually
this is something that you must do yourself. Edit the file
to set a primary and a secondary dns resolver. You can use the Google
dns resolvers at 184.108.40.206 and 220.127.116.11 or, if you prefer, there is a list
of public DNS servers at public-dns.info.
# /etc/resolv.conf nameserver 18.104.22.168 nameserver 22.214.171.124