Hi guys,
Set up a droplet having the private networking option enabled. My aim is to:
I tried both these iptables (flipped order between two options), to absolutely no avail:
:INPUT ACCEPT [3:180]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [255:30170]
-A FORWARD -i eth0 -j DROP
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
COMMIT
and
:INPUT ACCEPT [3:180]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [255:30170]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i eth0 -j DROP
COMMIT
Testing the changes this way:
Go on another droplet, and ssh using both of these:
ssh username@targetpublicip
and
ssh username@targetprivateip
In both cases, both keep working fine.
When I tried just this in the iptables:
iptables -I INPUT -i eth0 -j DROP
I couldn’t SSH using the private IP either.
I’m using the ams2 datacentre for both droplets.
Thanks and regards
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
First clear the existing iptables rules by running these commands
iptables -F
iptables -X
After you clean you can view the rules with
iptables -L
Then run in terminal the following rules
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
iptables -A INPUT -s x.x.x.x -j ACCEPT
iptables -A OUTPUT -d x.x.x.x -j ACCEPT
Note: Save the iptables rules before restarting your droplet so they don’t get lost
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.