IPTables Ignoring Rule To Redirect Web Traffic
up vote
-1
down vote
favorite
I am trying to do something very simple. I am trying to force all web request to go to my local webserver. I start by activating said webserver on my Kali Linux VirtualBox machine
sudo systemctl start apache2
Then I redirect all web traffic with iptables
sudo iptables -t nat -A PREROUTING -p tcp --dport 443 -j DNAT --to-destination 127.0.0.1:80
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1:80
Check to make sure the changes took effect
sudo iptables -t nat -L
They did
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
DNAT tcp -- anywhere anywhere tcp dpt:https to:127.0.0.1:80
Now when I go to google.com or even example.com I just go to google.com as I normally would. How can I make the changes actually take effect?
linux networking iptables redirection administration
add a comment |
up vote
-1
down vote
favorite
I am trying to do something very simple. I am trying to force all web request to go to my local webserver. I start by activating said webserver on my Kali Linux VirtualBox machine
sudo systemctl start apache2
Then I redirect all web traffic with iptables
sudo iptables -t nat -A PREROUTING -p tcp --dport 443 -j DNAT --to-destination 127.0.0.1:80
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1:80
Check to make sure the changes took effect
sudo iptables -t nat -L
They did
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
DNAT tcp -- anywhere anywhere tcp dpt:https to:127.0.0.1:80
Now when I go to google.com or even example.com I just go to google.com as I normally would. How can I make the changes actually take effect?
linux networking iptables redirection administration
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I am trying to do something very simple. I am trying to force all web request to go to my local webserver. I start by activating said webserver on my Kali Linux VirtualBox machine
sudo systemctl start apache2
Then I redirect all web traffic with iptables
sudo iptables -t nat -A PREROUTING -p tcp --dport 443 -j DNAT --to-destination 127.0.0.1:80
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1:80
Check to make sure the changes took effect
sudo iptables -t nat -L
They did
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
DNAT tcp -- anywhere anywhere tcp dpt:https to:127.0.0.1:80
Now when I go to google.com or even example.com I just go to google.com as I normally would. How can I make the changes actually take effect?
linux networking iptables redirection administration
I am trying to do something very simple. I am trying to force all web request to go to my local webserver. I start by activating said webserver on my Kali Linux VirtualBox machine
sudo systemctl start apache2
Then I redirect all web traffic with iptables
sudo iptables -t nat -A PREROUTING -p tcp --dport 443 -j DNAT --to-destination 127.0.0.1:80
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1:80
Check to make sure the changes took effect
sudo iptables -t nat -L
They did
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
DNAT tcp -- anywhere anywhere tcp dpt:https to:127.0.0.1:80
Now when I go to google.com or even example.com I just go to google.com as I normally would. How can I make the changes actually take effect?
linux networking iptables redirection administration
linux networking iptables redirection administration
edited 23 hours ago
asked 23 hours ago
user21303
296
296
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
When you go to google.com, your packet never visit PREROUTING chain.
Use OUTPUT instead.
I tried your suggestion. sudo iptables -t nat -A OUTPUT -p tcp --dport 443 -j DNAT --to-destination 127.0.0.1:80 sudo iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1:80 . But after doing sudo iptables -L it looks like the output command is not being added. What did I do wrong?
– user21303
23 hours ago
Wait, nevermind. It's working.
– user21303
22 hours ago
I'm receiving an error stating that this site can not provide a secure connection. I suppose I should not be surprised when considering HTTPS. Which begs the question, how do coffee shops redirect users to the terms of service page people need to agree to before they start using the internet?
– user21303
22 hours ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
When you go to google.com, your packet never visit PREROUTING chain.
Use OUTPUT instead.
I tried your suggestion. sudo iptables -t nat -A OUTPUT -p tcp --dport 443 -j DNAT --to-destination 127.0.0.1:80 sudo iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1:80 . But after doing sudo iptables -L it looks like the output command is not being added. What did I do wrong?
– user21303
23 hours ago
Wait, nevermind. It's working.
– user21303
22 hours ago
I'm receiving an error stating that this site can not provide a secure connection. I suppose I should not be surprised when considering HTTPS. Which begs the question, how do coffee shops redirect users to the terms of service page people need to agree to before they start using the internet?
– user21303
22 hours ago
add a comment |
up vote
0
down vote
accepted
When you go to google.com, your packet never visit PREROUTING chain.
Use OUTPUT instead.
I tried your suggestion. sudo iptables -t nat -A OUTPUT -p tcp --dport 443 -j DNAT --to-destination 127.0.0.1:80 sudo iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1:80 . But after doing sudo iptables -L it looks like the output command is not being added. What did I do wrong?
– user21303
23 hours ago
Wait, nevermind. It's working.
– user21303
22 hours ago
I'm receiving an error stating that this site can not provide a secure connection. I suppose I should not be surprised when considering HTTPS. Which begs the question, how do coffee shops redirect users to the terms of service page people need to agree to before they start using the internet?
– user21303
22 hours ago
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
When you go to google.com, your packet never visit PREROUTING chain.
Use OUTPUT instead.
When you go to google.com, your packet never visit PREROUTING chain.
Use OUTPUT instead.
answered 23 hours ago
Ipor Sircer
3,34411013
3,34411013
I tried your suggestion. sudo iptables -t nat -A OUTPUT -p tcp --dport 443 -j DNAT --to-destination 127.0.0.1:80 sudo iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1:80 . But after doing sudo iptables -L it looks like the output command is not being added. What did I do wrong?
– user21303
23 hours ago
Wait, nevermind. It's working.
– user21303
22 hours ago
I'm receiving an error stating that this site can not provide a secure connection. I suppose I should not be surprised when considering HTTPS. Which begs the question, how do coffee shops redirect users to the terms of service page people need to agree to before they start using the internet?
– user21303
22 hours ago
add a comment |
I tried your suggestion. sudo iptables -t nat -A OUTPUT -p tcp --dport 443 -j DNAT --to-destination 127.0.0.1:80 sudo iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1:80 . But after doing sudo iptables -L it looks like the output command is not being added. What did I do wrong?
– user21303
23 hours ago
Wait, nevermind. It's working.
– user21303
22 hours ago
I'm receiving an error stating that this site can not provide a secure connection. I suppose I should not be surprised when considering HTTPS. Which begs the question, how do coffee shops redirect users to the terms of service page people need to agree to before they start using the internet?
– user21303
22 hours ago
I tried your suggestion. sudo iptables -t nat -A OUTPUT -p tcp --dport 443 -j DNAT --to-destination 127.0.0.1:80 sudo iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1:80 . But after doing sudo iptables -L it looks like the output command is not being added. What did I do wrong?
– user21303
23 hours ago
I tried your suggestion. sudo iptables -t nat -A OUTPUT -p tcp --dport 443 -j DNAT --to-destination 127.0.0.1:80 sudo iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1:80 . But after doing sudo iptables -L it looks like the output command is not being added. What did I do wrong?
– user21303
23 hours ago
Wait, nevermind. It's working.
– user21303
22 hours ago
Wait, nevermind. It's working.
– user21303
22 hours ago
I'm receiving an error stating that this site can not provide a secure connection. I suppose I should not be surprised when considering HTTPS. Which begs the question, how do coffee shops redirect users to the terms of service page people need to agree to before they start using the internet?
– user21303
22 hours ago
I'm receiving an error stating that this site can not provide a secure connection. I suppose I should not be surprised when considering HTTPS. Which begs the question, how do coffee shops redirect users to the terms of service page people need to agree to before they start using the internet?
– user21303
22 hours ago
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1374938%2fiptables-ignoring-rule-to-redirect-web-traffic%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password