Hi im charlie, single dad to two children. this blog is to talk about anything i find intresting. From computing with linux to RC cars to dog walks.
“To whom it may concern, fuck you.”
Valterri Bottas
-
Adding a secondary IP address to a ubuntu 22.04 Server
This article describes how to add an additional ip address to your ubuntu server
Step 1
Log in to your server via SSH as the root user.
Step 2
Once logged in, you will need to collect some information required to configure the network correctly.
Network device name
To display the default gateway of the active interface, enter the following command:
ls /sys/class/net
Here is an example output:
eth0 eth1 lo tun0 usb0
Ignore the ‘lo’ device, but make note of the other network device in the list, in the example above ours is ‘eth0, eth1’
DNS nameserver
To display the DNS servers used, enter the following command:
resolvectl --no-pager |grep Server
Here is an example output:
ls
Current DNS Server: 212.227.123.16 DNS Servers: 212.227.123.16 212.227.123.17 DNS Servers: 2001:8d8:fe:53:72ec::1 2001:8d8:fe:53:72ec::2 212.227.123.16
Make a note of the ‘DNS Servers’.
Default gateway
To display the default gateway of the active interface, enter the following command:
ip route show | grep 'default'
Take note of the IP address listed directly after the ‘default via‘ part, for example:
default via 10.255.255.1 dev eth0 proto static onlink
In this example, the default gateway is 10.255.255.1
Step 3
Locate the existing network configuration file. Use this command to navigate into the folder where the file exists:
cd /etc/netplan
You can then list the files in the folder using this command:
ll
Make a note of the name of the configuration file. In this example, the name of the configuration file is 00-Public_network.yaml.
root@localhost:~# cd /etc/netplan root@localhost:/etc/netplan# ll -rw-r--r-- 1 root root 87 Apr 3 18:33 00-Public_network.yaml
Step 4
Once you have the name of the current configuration file, you can rename it by adding .bak to the end of the file name.
Use the command below to do this. Replace 00-Public_network.yaml with the name of the file from the last step.
mv 00-Public_network.yaml 00-Public_network.yaml.bak
This will allow you to keep it as backup configuration file which you know works.
Step 5.
Use a text editor to create and open your new configuration file. For this example we will use nano:
nano 00-Public_network.yaml
Step 6
copy and paste the text below into the new empty file:
Please be aware that the formatting of the file is very specific due to the use of the YAML language, please use spaces for the indentations
network: renderer: networkd ethernets: NETWORKDEVICENAME: addresses: - PRIMARY-IP/32 - SECONDARY-IP/32 nameservers: addresses: [PRIMARY-NS, SECONDARY-NS] routes: - on-link: true to: default via: GATEWAY version: 2
Step 7
To fill out the configuration file you will need to know the IP addresses associated with your server (available in your control panel) along with the information from step 1.
- Replace NETWORKDEVICENAME with the network device name from step 1.
- Replace PRIMARY-IP with the main IP address of your server.
- Replace SECONDARY-IP with the new IP address you are adding. You can add more lines, in the same format, for additional IPs.
- Replace PRIMARY-NS and SECONDARY NS with the DNS servers from step 1.
- Replace GATEWAY with the default gateway from step 1.
For our example, the final configuration looks like this:
network: renderer: networkd ethernets: eth0: addresses: - 77.68.125.213 /32 - 77.68.125.216 /32 nameservers: addresses: - 212.227.123.16 - 212.227.123.17 routes: - on-link: true to: default via: 10.255.255.1 version: 2
Save the file and close your text editor.
If you are using nano, you can save the file with CTRL+O then use CTRL+X to exit.
Step 8
To apply this new configuration, run the following command:
netplan --debug apply
ou may receive warnings about the permissions of the new file, but the new configuration should still work.
To correct the permission warnings, run the following command, replacing 00-Public_network.yaml with the name of your configuration file:
chmod 600 /etc/netplan/00-Public_network.yaml
This will make the file only readable and writable by root
Step 9
To verify that your configuration is correct, enter the following command:
ip addr
Look for the line that starts with your device name, you should see your IP addresses:
[root@localhost:/etc/netplan]# ip addr 2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:50:56:2c:11:e9 brd ff:ff:ff:ff:ff:ff altname enp11s0 inet 77.68.28.139/32 scope global ens192 valid_lft forever preferred_lft forever inet 77.68.114.76/32 scope global ens192 valid_lft forever preferred_lft forever
-
Connecting to your Linux server using SSH
This article describes how to connect to your Linux server with SSH, using the PuTTy and MTPuTTy clients with Windows operating systems.
1. Using the PuTTy client
Step 1.
First you need to download the putty client. To find the latest version use this link. for direct download press the button below1
Step 2.
Start your Putty client, type in the IP address of your server, select port 22 (default), select the SSH protocol and click Open.
If required you should save the configuration. Type a name into the Saved sessions box and click the Save button.
At the very first SSH login, you will be prompted to accept the host server security key. Click Yes. The key will hereafter be cached by your Putty client. Step 3.
Type in root as your username and hit enter. You will now be prompted for your password. Type in the password and your login will be complete.
There will appear to be no input when typing in your password, this is normal. Alternatively you can paste a password using the right mouse button. Logging out
To log out from your Putty SSH session, type exit at the prompt.
-
minecraft server setup commands
install minecraft server
java -Xms16024M -Xmx16024M -jar minecraft_server_1.19.2.jar nogui
install forge server
java -jar forge-1.19.2-43.3.9-installer.jar –installServer
to start a screen instance
screen -S “name”
screen -S minecraftto start vanilla minecraft server
java -Xms16024M -Xmx16024M -jar minecraft_server_1.19.2.jar nogui
To disconnect from screen
ctrl A+D
to reconnect to screen
screen -r “name”
screen -r minecraftto list active screens
screen -ls
to start minecraft run.sh
sh run.sh
-
OpenVPN Install Ubuntu
This quick tutorial will teach you how to quickly install openVPN
First we need to download the installer. log into your ssh terminal i recomend Multi Tabbed Putty. you can download via this link.
Once singed in run this command to download openvpn-install.sh
wget https://git.io/vpn -O openvpn-install.sh
Then run this comand to change the permissions
sudo chmod +x openvpn-install.sh
once you have changed the permissions run this command to run the installer
sudo bash openvpn-install.sh
Once the command has been run you will be met with these following options, we recommed these settings.
Welcome to this OpenVPN road warrior installer!
Which protocol should OpenVPN use?
1) UDP (recommended)
2) TCP
Protocol [1]: 1What port should OpenVPN listen to?
Port [1194]:Select a DNS server for the clients:
1) Current system resolvers
2) Google
3) 1.1.1.1
4) OpenDNS
5) Quad9
6) AdGuard
DNS server [1]: 2Enter a name for the first client:
Name [client]: DesktopOpenVPN installation is ready to begin.
Press any key to continue…Too add more users, run this command again
sudo bash openvpn-install.sh
Your openVPN config file will be created at your /root/ directory