Ubuntu Networking: Difference between revisions
From embeddedTS Manuals
(Created page with "From almost any Linux system you can use "ip" or the ifconfig/route commands to initially set up the network. <source lang=bash> # Bring up the CPU network interface ifconfig ...") |
Tag: Undo |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
From almost any Linux system you can use "ip" or the ifconfig/route commands to | From almost any Linux system you can use "ip" or the ifconfig/route commands to set up the network. | ||
<source lang=bash> | <source lang=bash> | ||
# Bring up the CPU network interface | # Bring up the CPU network interface | ||
Line 20: | Line 20: | ||
</source> | </source> | ||
Most | Most networks will offer DHCP which can be set up with one command: | ||
<source lang=bash> | <source lang=bash> | ||
# To setup the default CPU ethernet port | # To setup the default CPU ethernet port | ||
Line 30: | Line 30: | ||
</source> | </source> | ||
To make | To make DHCP run on startup systemd's networking will need to be configured. | ||
In /etc/systemd/network/eth.network | In /etc/systemd/network/eth.network | ||
Line 48: | Line 48: | ||
</source> | </source> | ||
For a static configuration | For a static configuration create a config file for that specific interface. | ||
/etc/systemd/network/eth0.network | /etc/systemd/network/eth0.network | ||
<source lang=ini> | <source lang=ini> | ||
Line 60: | Line 60: | ||
</source> | </source> | ||
For more information on networking, see | For more information on networking, see Ubuntu and systemd's documentation: | ||
* [http://www.freedesktop.org/software/systemd/man/systemd.network.html Systemd Networking Documentation] | * [http://www.freedesktop.org/software/systemd/man/systemd.network.html Systemd Networking Documentation] | ||
* [https://help.ubuntu.com/lts/serverguide/network-configuration.html Ubuntu Documentation] | * [https://help.ubuntu.com/lts/serverguide/network-configuration.html Ubuntu Documentation] |
Latest revision as of 11:54, 22 September 2023
From almost any Linux system you can use "ip" or the ifconfig/route commands to set up the network.
# Bring up the CPU network interface
ifconfig eth0 up
# Or if you're on a baseboard with a second ethernet port, you can use that as:
ifconfig eth1 up
# Set an ip address (assumes 255.255.255.0 subnet mask)
ifconfig eth0 192.168.0.50
# Set a specific subnet
ifconfig eth0 192.168.0.50 netmask 255.255.0.0
# Configure your route. This is the server that provides your internet connection.
route add default gw 192.168.0.1
# Edit /etc/resolv.conf for your DNS server
echo "nameserver 192.168.0.1" > /etc/resolv.conf
Most networks will offer DHCP which can be set up with one command:
# To setup the default CPU ethernet port
dhclient eth0
# Or if you're on a baseboard with a second ethernet port, you can use that as:
dhclient eth1
# You can configure all ethernet ports for a dhcp response with
dhclient
To make DHCP run on startup systemd's networking will need to be configured.
In /etc/systemd/network/eth.network
[Match]
Name=eth*
[Network]
DHCP=yes
Then, if you intend to use DHCP to configure your DNS, start and enable the network name resolver service:
systemctl start systemd-resolved.service
systemctl enable systemd-resolved.service
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
For a static configuration create a config file for that specific interface. /etc/systemd/network/eth0.network
[Match]
Name=eth0
[Network]
Address=192.168.0.50/24
Gateway=192.168.0.1
DNS=192.168.0.1
For more information on networking, see Ubuntu and systemd's documentation: