Score:0

Create a loopback, masked ip?

cn flag

So, I have a project on my Ubuntu 18.04 LTS (64bits) VPS that don't work with the normal IP (like 5.123.246.77), it only work with a network mask. The problem is that I can't manage to mask it correctly, because I always get these errors:

SIOCSIFADDR: File exists
SIOCSIFFLAGS: Cannot assign requested address
SIOCSIFNETMASK: Cannot assign requested address
SIOCSIFFLAGS: Cannot assign requested address

Heres my ./start script

#!/bin/bash

cat /dev/null > /var/log/syslog
cat /dev/null > /var/log/wtmp 
cat /dev/null > /var/log/maillog
cat /dev/null > /var/log/messages
cat /dev/null > /var/log/openwebmail.log
cat /dev/null > /var/log/maillog
cat /dev/null > /var/log/secure

find . -name "*.log.*" -type f -print -exec rm -rf {} \;


LANG=
LC_CTYPE="POSIX"
LC_NUMERIC=en_US.UTF-8
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
export LC_ALL=C

sudo ifconfig lo:0  10.10.215.101  netmask 255.0.0.0 up
sudo ifconfig lo:1  10.10.215.116  netmask 255.0.0.0 up
sudo ifconfig lo:2  10.10.215.101  netmask 255.0.0.0 up
sudo ifconfig lo:3  10.10.215.130  netmask 255.0.0.0 up
sudo ifconfig lo:4  10.10.215.131  netmask 255.0.0.0 up
sudo ifconfig lo:5  10.10.215.132  netmask 255.0.0.0 up
sudo ifconfig lo:6  10.10.215.11   netmask 255.0.0.0 up
sudo ifconfig lo:7  10.10.215.12   netmask 255.0.0.0 up
sudo ifconfig lo:8  10.10.215.21   netmask 255.0.0.0 up
sudo ifconfig lo:9  10.10.215.22   netmask 255.0.0.0 up
sudo ifconfig lo:10 10.10.10.100   netmask 255.0.0.0 up
sudo ifconfig lo:11 10.10.10.101   netmask 255.0.0.0 up
sudo ifconfig lo:12 10.10.10.102   netmask 255.0.0.0 up
sudo ifconfig lo:13 10.10.10.103   netmask 255.0.0.0 up
sudo ifconfig lo:14 10.10.10.11    netmask 255.0.0.0 up
sudo ifconfig lo:15 10.1.0.0       netmask 255.0.0.0 up
sudo ifconfig lo:16 10.10.0.126    netmask 255.0.0.0 up
sudo ifconfig lo:17 10.1.0.1       netmask 255.0.0.0 up


iptables -t nat -F

sudo ifconfig lo:18 10.10.215.99   netmask 255.0.0.0 up
sudo sysctl net.ipv4.ip_forward=1
sudo iptables -t nat -A PREROUTING -p tcp --dport 5567 -j DNAT --to-destination 10.10.215.101:5567
sudo iptables -t nat -A PREROUTING -p tcp --dport 10021 -j DNAT --to-destination 10.10.215.101:10021
sudo iptables -t nat -A PREROUTING -p tcp --dport 7777 -j DNAT --to-destination 10.10.215.101:7777
sudo iptables -t nat -A PREROUTING -p tcp --dport 5560 -j DNAT --to-destination 10.10.215.101:5560
sudo iptables -t nat -A POSTROUTING -j MASQUERADE

My eth0 is named enp0s3. Both 10.10.215.99 and 10.10.215.101 ips are being used by my project, with the ports being 5567, 10021, 7777, 5560.

What am I doing wrong? How to fix those SIOCSI erros? =/

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.