Add docs/tech_docs/linux/debian_networking.md
This commit is contained in:
93
docs/tech_docs/linux/debian_networking.md
Normal file
93
docs/tech_docs/linux/debian_networking.md
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
Certainly! Here's a more detailed guide on how to manage network configurations on a Debian 12 server using different methods, with additional context and instructions tailored to your preference for using VIM as a text editor.
|
||||||
|
|
||||||
|
### Network Configuration on Debian 12
|
||||||
|
|
||||||
|
Debian 12 can manage network configurations through traditional Debian methods like the `/etc/network/interfaces` file, or modern methods such as `systemd-networkd` and NetworkManager. Below is a comprehensive guide on how to adjust the default route using these methods, and how to use VIM for editing configuration files.
|
||||||
|
|
||||||
|
### 1. Using `/etc/network/interfaces`
|
||||||
|
|
||||||
|
For servers not using NetworkManager or `systemd-networkd`, the network settings are traditionally managed via the `/etc/network/interfaces` file.
|
||||||
|
|
||||||
|
**Steps to modify the default route:**
|
||||||
|
|
||||||
|
- **Open the configuration file with VIM**:
|
||||||
|
```bash
|
||||||
|
sudo vim /etc/network/interfaces
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Configure your network interface**: Here's an example of what your configuration might look like if you're setting a static IP and want to define which gateway the server should use:
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
auto eth0
|
||||||
|
iface eth0 inet static
|
||||||
|
address 192.168.1.100
|
||||||
|
netmask 255.255.255.0
|
||||||
|
gateway 192.168.1.1
|
||||||
|
```
|
||||||
|
|
||||||
|
Make sure to replace `eth0` with the correct interface name, and update the `address`, `netmask`, and `gateway` with appropriate values for your network. Only set the `gateway` for the interface that should be the default route.
|
||||||
|
|
||||||
|
- **Restart networking to apply changes**:
|
||||||
|
```bash
|
||||||
|
sudo systemctl restart networking
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Using `systemd-networkd`
|
||||||
|
|
||||||
|
If your server uses `systemd-networkd` for managing network interfaces, you'll configure them via `.network` files located in `/etc/systemd/network/`.
|
||||||
|
|
||||||
|
- **Create or edit a network file for your interface**:
|
||||||
|
```bash
|
||||||
|
sudo vim /etc/systemd/network/10-eth0.network
|
||||||
|
```
|
||||||
|
|
||||||
|
Here is what the configuration might look like:
|
||||||
|
```plaintext
|
||||||
|
[Match]
|
||||||
|
Name=eth0
|
||||||
|
|
||||||
|
[Network]
|
||||||
|
DHCP=no
|
||||||
|
Address=192.168.1.100/24
|
||||||
|
Gateway=192.168.1.1
|
||||||
|
DNS=8.8.8.8
|
||||||
|
```
|
||||||
|
|
||||||
|
Adjust the interface name and network settings as necessary.
|
||||||
|
|
||||||
|
- **Restart `systemd-networkd` to apply changes**:
|
||||||
|
```bash
|
||||||
|
sudo systemctl restart systemd-networkd
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Using NetworkManager
|
||||||
|
|
||||||
|
For servers with a graphical interface or for those preferring NetworkManager:
|
||||||
|
|
||||||
|
- **Edit connections using NMTUI**, or for command line changes:
|
||||||
|
```bash
|
||||||
|
nmcli connection modify <connection-name> ipv4.addresses "192.168.1.100/24" ipv4.gateway "192.168.1.1" ipv4.dns "8.8.8.8" ipv4.method manual
|
||||||
|
```
|
||||||
|
Replace `<connection-name>` with the name of your connection.
|
||||||
|
|
||||||
|
- **Apply changes**:
|
||||||
|
```bash
|
||||||
|
nmcli connection up <connection-name>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Making Temporary Changes
|
||||||
|
|
||||||
|
For temporary routing adjustments:
|
||||||
|
|
||||||
|
- **Delete the existing default route**:
|
||||||
|
```bash
|
||||||
|
sudo ip route del default
|
||||||
|
```
|
||||||
|
- **Add a new default route**:
|
||||||
|
```bash
|
||||||
|
sudo ip route add default via 192.168.1.1 dev eth0
|
||||||
|
```
|
||||||
|
|
||||||
|
These commands will modify the routing table until the next reboot or restart of the network service.
|
||||||
|
|
||||||
|
This comprehensive guide should help you manage your Debian server's network settings effectively. Whether you're making temporary changes or configuring settings for long-term use, these steps will ensure your network is set up according to your needs.
|
||||||
Reference in New Issue
Block a user