last day (1 day later) » 

14:18
1
Q: How to Configure Debian Server with ISP-Delegated Static IPs?

b.sullenderI'm setting up a Debian server to act as both a router and a server, but I've encountered issues with my ISP's unique static IP assignment method. Here's the situation: I have been assigned two static IPs: 66.161.243.109 and 66.161.243.110 with a subnet mask of 255.255.255.252. My goal is to assi...

Does this setup work without the virtual interface and iptables rule?
@RobM yes, if I only remove the iptables rule then it works, but the dynamic IP address from DHCP (the ONT) is used as the public IP address instead of the desired static IP. Same thing without the virtual interface, it works through the dynamic IP.
Have you been able to use your static IPs in the intended way? I'm just trying to get my head around what's going wrong, because from the sounds of it your setup should work.
What happens if you just have the virtual interface but no iptables rule? If that works but connections default to the dynamic ip, try curl --bind 66.161.243.109 ifconfig.me or curl --bind eno1:1 ifconfig.me
@RobM yes, I had a ZyXEL ZyWALL 110 router that i used to route both of the static IPs to my other servers/devices. It was setup using virtual interface, SNAT and routing table, but the router itself used the dynamic IP address, if that makes sense. curl option --bind is unknown, but if i use curl --interface 66.161.243.109 ifconfig.me or curl --interface eno1:1 ifconfig.me then it does show the static IP as desired.
Oh right you are, 2 am moment. That's great, your setup does work, the trick is just going to be getting the little details right. Is it very important to you that everything you do appear to be coming from your static IP, or do you only have a few services where that's important?
14:18
My desired setup would be anything the server does would appear to be coming from the static IP, except for those connected through eno2 (isc-dhcp-server), they would use the dynamic IP. If not possible, then everything uses the static IP.
the website prompted me to move this to a chat, if it's all the same to you
Its fine with me.
I didn't know there was a chat feature
I'm doing some research into how to make this work how you want, but it's absolutely beyond me why it's so complicated
OK. I have tried so many different settings and configurations. Been working on it all week, but I'm no expect when it comes to networking. Using curl with --interface was the 1st the i saw the server actually use the static IP, so that makes me happy were on the right track.
14:47
see if you can replicate what i've done here, i don't know if this will translate to anything you can set up in the interfaces file, but it's a lead. possibly if those values don't change day to day, you can just hard-code the command into the config
OK, I'm checking what you did.
hopefully that screenshot makes sense, it's a bit dense to follow what's going on, but i can answer any questions
Gonna try it now. You might see me leave the chat temporally.
The command executed fine, but curl ifconfig.me still returns the dynamic IP.
ip route change 50.5.173.0/24 dev eno1 src 66.161.243.109 was the command. Where 50.5.173.0/24 was the dynamic route from ip route.
15:10
and if you run ip route it shows src 66.161.243.109?
yea, its listed as src for the dynamic route.
15:24
well i'm at a bit of a loss then. I had a look at your source NAT rule too, and that looks like it should work too, it worked in my setup. did you try adding the iptables rule manually after everything had started up?
Yea, i definitely tried that too.
Something about how my ISP routes these IPs is making the NAT rule not work i think. Maybe the subnet mask not being sent, just my guess.
and the rule adds okay?
The NAT rule adds fine, but that causes 100% packet loss for ping and curl hangs indefinitely.
Hang on, let me try the NAT rule with the change we just made.
in terms of what the isp sees, making a connection using the static ip natively and SNATing to the static ip should be indistinguishable, the IP packet itself doesn't carry information about the subnet
@b.sullender go nuts, but it shouldn't make a difference
OK, ill give it a try until we think of something.
OMG, using my SNAT rule with the route command work! Just needed both!
curl ifconfig.me returns the static IP now.
15:35
there must be something i'm missing, because either of them should work on their own, and using them together shouldn't do anything different, but whatever gets the job done lol
Yea i agree, that doesn't make much sense actually.
I'm gonna try connecting to my server over ssh using the static IP
i would maybe get the interfaces file set up to run the ip route command and make sure the setup survives being rebooted, and then try commenting out the iptables and leaving the ip route, or comment out the ip route and leave the iptables. if it only works with both, there must be something crazy going on
Yea ill try that. How would i even do the ip route command in the interfaces file without knowing the dynamic 50.5.173.0/24 address? Is that even possible?
so that's the thing i mentioned about the parameters changing, if the ip you're allocated is always on the same subnet then you're all set to hard code it, but otherwise you'd have to write something up to grab the subnet you're on and craft the command based on that
just shooting from the hip, something like this
50.5.173.0/24 definitely changes, it was something else a few days ago.
15:51
you know what i just realized why my setup for testing this might be limited, the 2 ip addresses i was messing with were on the same subnet, but yours are on different subnets
it's getting late but i'll have to try setting up a more elaborate test environment that's closer to what you've got
OK, ill do some more tests. and see what i can find out. Are we able to come back to this chat?
yeah i think so, i don't know if i'll get notifications but i'll try to remember to check back
good luck. i know it's a bit trite and cliche but i really do believe this, when you spend so long tearing your hair out working on a problem like this, tell yourself that it means you're about to learn something interesting, it helps a bit lol
lol ill keep that in mind, good advice! hope you get good rest, I'm just starting my day ;)
 
6 hours later…
22:01
Testing showed weird behavior, decided to do a reinstall of Debian and start over. Turns out the SNAT rule was enough for it to work. I think maybe i had changed a setting or configuration that was causing issues before. Not sure why it would cause packet loss for ping, and curl to hang before. This has been a learning curve for me. Thanks for helping and trying to narrow down the problem.
If you want to post an answer as a configuration conflict, and try reinstall, ill accept it. I'm not sure if i should delete the post.

last day (1 day later) »