Files
the_information_nexus/docs/tech_docs/OpenWrt.md

216 lines
5.5 KiB
Markdown

```bash
pct start 101
```
```bash
pct stop 101
```
```bash
pct destroy 101
```
```bash
pct console 101
```
```bash
pct reboot 101
```
### Proxmox Container Creation
Use the following command to create a new container with reduced memory and storage:
```bash
pct create 101 /var/lib/vz/template/cache/openwrt-rootfs.tar.xz --unprivileged 1 --arch amd64 --ostype unmanaged --hostname openwrt-01 --tag network --storage local-lvm --memory 128 --swap 0 --rootfs local-lvm:1,size=512M \
--net0 name=eth0,bridge=vmbr0,firewall=1 \
--net1 name=eth1,bridge=vmbr1,firewall=1
```
### OpenWRT Firewall Configuration
```bash
passwd
```
```bash
vi /etc/config/network
```
```bash
config interface 'loopback'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
option device 'lo'
config interface 'wan'
option proto 'dhcp'
option device 'eth0'
config interface 'wan6'
option proto 'dhcpv6'
option device 'eth0'
config interface 'lan'
option ifname 'eth1'
option proto 'static'
option device 'eth1'
option ipaddr '10.0.0.1'
option netmask '255.255.255.0'
```
```bash
vi /etc/config/firewall
```
```bash
config rule
option name 'Allow-SSH'
option src 'wan'
option proto 'tcp'
option dest_port '22'
option target 'ACCEPT'
config rule
option name 'Allow-HTTPS'
option src 'wan'
option proto 'tcp'
option dest_port '443'
option target 'ACCEPT'
config rule
option name 'Allow-HTTP'
option src 'wan'
option proto 'tcp'
option dest_port '80'
option target 'ACCEPT'
```
### Applying the Configuration
After updating the configuration files:
- **Restart Network Services**:
```bash
/etc/init.d/network restart
```
- **Reload Firewall Settings**:
```bash
/etc/init.d/firewall restart
```
### Installing Packages via CLI
1. **Update the Package List**: Before installing any new packages, it's a good practice to update the list of packages to ensure you are installing the latest versions available. You can do this by running:
```bash
opkg update
```
```bash
opkg install qemu-ga
```
```bash
poweroff
```
---
OpenWRT Container (ID: 100):
```bash
pct create 100 /var/lib/vz/template/cache/openwrt-rootfs.tar.xz --unprivileged 1 --arch amd64 --ostype unmanaged --hostname openwrt-0 --tag network --storage local-lvm --cores 2 --memory 128 --swap 0 --rootfs local-lvm:1,size=512M --net0 name=eth0,bridge=vmbr0,firewall=1 --net1 name=eth1,bridge=vmbr1,firewall=1
```
Kali Linux Container (ID: 200):
```bash
pct create 200 /var/lib/vz/template/cache/kali-default-rootfs.tar.xz --unprivileged 1 --arch amd64 --ostype debian --hostname kali-0 --tag tools --storage local-lvm --cores 2 --memory 1024 --swap 512 --rootfs local-lvm:1,size=8G --net0 name=eth0,bridge=vmbr1,firewall=1
```
Alpine Container (ID: 300):
```bash
pct create 300 /var/lib/vz/template/cache/alpine-default-rootfs.tar.xz --unprivileged 1 --arch amd64 --ostype alpine --hostname alpine-0 --tag docker --storage local-lvm --cores 2 --memory 1024 --swap 256 --rootfs local-lvm:1,size=8G --net0 name=eth0,bridge=vmbr1,firewall=1
```
---
For your standalone Proxmox setup, switching between static and dynamic IP configurations and managing virtual bridges are important tasks. Below, I'll provide a concise guide to handle these changes effectively and safely.
### Switching from Static IP to DHCP:
- **Backup Configurations:** Always backup configuration files before making changes (`cp /etc/network/interfaces /etc/network/interfaces.bak`).
```bash
cp /etc/network/interfaces /etc/network/interfaces.bak
```
1. **Update Network Interface Configuration:**
- Open `/etc/network/interfaces` in a text editor:
```bash
nano /etc/network/interfaces
```
- Change the `vmbr0` configuration from static to DHCP:
```bash
auto vmbr0
iface vmbr0 inet dhcp
bridge-ports enp3s0
bridge-stp off
bridge-fd 0
```
- Save the changes and exit the editor.
2. **Restart Networking to Apply Changes:**
- Apply the new network settings:
```bash
systemctl restart networking
```
3. **Find the New DHCP-Assigned IP Address:**
- After the network restarts, check the assigned IP:
```bash
ip addr show vmbr0
```
4. **Update `/etc/hosts` with the New IP:**
- Edit the `/etc/hosts` file to replace the old static IP with the new one:
```bash
nano /etc/hosts
```
- Modify the line with the old IP to the new one you just obtained:
```plaintext
192.168.86.62 whitebox.foxtrot.lan whitebox # Old IP
192.168.x.x whitebox.foxtrot.lan whitebox # New DHCP IP
```
- Save and exit.
5. **Reserve IP in DHCP Server (Optional but Recommended):**
- To ensure the IP does not change on reboots, reserve the IP in your DHCP server settings to always assign the same IP to the MAC address of `vmbr0`.
### Creating a New Virtual Bridge (`vmbrX`):
1. **Add a New Virtual Bridge Configuration:**
- Edit `/etc/network/interfaces`:
```bash
nano /etc/network/interfaces
```
- Add a new bridge configuration at the end of the file:
```bash
auto vmbrX # Replace X with the next available number
iface vmbrX inet manual
bridge-ports none
bridge-stp off
bridge-fd 0
```
- Save and exit the editor.
2. **Activate the New Bridge:**
- Restart the networking service to bring up the new bridge:
```bash
systemctl restart networking
```
### General Notes: