Hi all,
So, I'm trying to set up SSH so that it will only take incoming connections on one of two interfaces. I'm on a network running DHCP, so I can't do a "sshd -o I.P.a.ddress", since I can't guarantee that a given interface will always have the same IP. I got some help on Reddit creating a script that steals the current IP from ifconfig, but I can't figure out how to load it into sshd_config (apparently "cat [script] > sshd_config" doesn't work how I thought it did).
I did some reading online and found a lot of articles explaining how to set up iptables to allow an SSH connection (iptables -A INPUT -i eth1 -p tcp -m tcp --dport 22 -j DROP), and figured "well, since I want to disallow SSH on eth1 and allow it on eth0, this should work fine!" I entered the command, added /usr/local/sbin/basic-firewall to /opt/bootlocal.sh, and restarted. I then tried to SSH into both interfaces; neither one worked.
"Okay," I said, "What if I add a rule that allows SSH on eth0?" So, I did 'iptables -A INPUT -i eth0 -p tcp -m tcp --dport 22 -k ACCEPT', restarted, tried to SSH into both interfaces, and got into both. Argh.
Am I doing something entirely wrong? Is this even a Thing That Can Be Done?
Thanks!