Redirect all devices connected to AP of RPI to the IP address of RPI

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I have a Pi with AP and static ip address 192.168.1.2. Devices connecting to the pi will have IP addresses between the range 192.168.1.2 to 192.168.1.20. I want to redirect all incoming web requests to redirect to the ip address of PI using iptables.



I have tried:



iptables -t nat -A PRETROUTING -p tcp --dport -j DNAT --to-destination 192.168.1.2






share|improve this question
















  • 1




    why not just assign a different IP subnet to the wlan interface? (and route that subnet to the rpi, of course)
    – cas
    Jan 13 at 7:06











  • ok. I will look into assigning a different IP subnet to the wlan interface. but how to route that subnet to the rpi? newbie to the linux here :(
    – AB pacino
    Jan 13 at 7:11










  • depends on what you're using for a router. if it's the rpi itself, you don't need to do anything else. otherwise just add a static route on your router for that IP subnet to the rpi's address. btw, you have PRETROUTING in your iptables command above...useful for fishing perhaps, but not routing :)
    – cas
    Jan 13 at 7:35











  • Google "transparent proxy".
    – dirkt
    Jan 13 at 9:28










  • @cas Thanks for your reply. I am using rpi itself as the router. i added address=/#/192.168.1.2 in dnsmasq.conf for redirection and for most of the requests, it works except for facebook and youtube. I think that is because of SSL certificate. If that's the case, it shouldn't work for google.com too but it does. Any idea what could be done. ? and about iptables, is there any command which can meet my needs?
    – AB pacino
    Jan 14 at 5:01














up vote
0
down vote

favorite












I have a Pi with AP and static ip address 192.168.1.2. Devices connecting to the pi will have IP addresses between the range 192.168.1.2 to 192.168.1.20. I want to redirect all incoming web requests to redirect to the ip address of PI using iptables.



I have tried:



iptables -t nat -A PRETROUTING -p tcp --dport -j DNAT --to-destination 192.168.1.2






share|improve this question
















  • 1




    why not just assign a different IP subnet to the wlan interface? (and route that subnet to the rpi, of course)
    – cas
    Jan 13 at 7:06











  • ok. I will look into assigning a different IP subnet to the wlan interface. but how to route that subnet to the rpi? newbie to the linux here :(
    – AB pacino
    Jan 13 at 7:11










  • depends on what you're using for a router. if it's the rpi itself, you don't need to do anything else. otherwise just add a static route on your router for that IP subnet to the rpi's address. btw, you have PRETROUTING in your iptables command above...useful for fishing perhaps, but not routing :)
    – cas
    Jan 13 at 7:35











  • Google "transparent proxy".
    – dirkt
    Jan 13 at 9:28










  • @cas Thanks for your reply. I am using rpi itself as the router. i added address=/#/192.168.1.2 in dnsmasq.conf for redirection and for most of the requests, it works except for facebook and youtube. I think that is because of SSL certificate. If that's the case, it shouldn't work for google.com too but it does. Any idea what could be done. ? and about iptables, is there any command which can meet my needs?
    – AB pacino
    Jan 14 at 5:01












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a Pi with AP and static ip address 192.168.1.2. Devices connecting to the pi will have IP addresses between the range 192.168.1.2 to 192.168.1.20. I want to redirect all incoming web requests to redirect to the ip address of PI using iptables.



I have tried:



iptables -t nat -A PRETROUTING -p tcp --dport -j DNAT --to-destination 192.168.1.2






share|improve this question












I have a Pi with AP and static ip address 192.168.1.2. Devices connecting to the pi will have IP addresses between the range 192.168.1.2 to 192.168.1.20. I want to redirect all incoming web requests to redirect to the ip address of PI using iptables.



I have tried:



iptables -t nat -A PRETROUTING -p tcp --dport -j DNAT --to-destination 192.168.1.2








share|improve this question











share|improve this question




share|improve this question










asked Jan 13 at 7:00









AB pacino

1




1







  • 1




    why not just assign a different IP subnet to the wlan interface? (and route that subnet to the rpi, of course)
    – cas
    Jan 13 at 7:06











  • ok. I will look into assigning a different IP subnet to the wlan interface. but how to route that subnet to the rpi? newbie to the linux here :(
    – AB pacino
    Jan 13 at 7:11










  • depends on what you're using for a router. if it's the rpi itself, you don't need to do anything else. otherwise just add a static route on your router for that IP subnet to the rpi's address. btw, you have PRETROUTING in your iptables command above...useful for fishing perhaps, but not routing :)
    – cas
    Jan 13 at 7:35











  • Google "transparent proxy".
    – dirkt
    Jan 13 at 9:28










  • @cas Thanks for your reply. I am using rpi itself as the router. i added address=/#/192.168.1.2 in dnsmasq.conf for redirection and for most of the requests, it works except for facebook and youtube. I think that is because of SSL certificate. If that's the case, it shouldn't work for google.com too but it does. Any idea what could be done. ? and about iptables, is there any command which can meet my needs?
    – AB pacino
    Jan 14 at 5:01












  • 1




    why not just assign a different IP subnet to the wlan interface? (and route that subnet to the rpi, of course)
    – cas
    Jan 13 at 7:06











  • ok. I will look into assigning a different IP subnet to the wlan interface. but how to route that subnet to the rpi? newbie to the linux here :(
    – AB pacino
    Jan 13 at 7:11










  • depends on what you're using for a router. if it's the rpi itself, you don't need to do anything else. otherwise just add a static route on your router for that IP subnet to the rpi's address. btw, you have PRETROUTING in your iptables command above...useful for fishing perhaps, but not routing :)
    – cas
    Jan 13 at 7:35











  • Google "transparent proxy".
    – dirkt
    Jan 13 at 9:28










  • @cas Thanks for your reply. I am using rpi itself as the router. i added address=/#/192.168.1.2 in dnsmasq.conf for redirection and for most of the requests, it works except for facebook and youtube. I think that is because of SSL certificate. If that's the case, it shouldn't work for google.com too but it does. Any idea what could be done. ? and about iptables, is there any command which can meet my needs?
    – AB pacino
    Jan 14 at 5:01







1




1




why not just assign a different IP subnet to the wlan interface? (and route that subnet to the rpi, of course)
– cas
Jan 13 at 7:06





why not just assign a different IP subnet to the wlan interface? (and route that subnet to the rpi, of course)
– cas
Jan 13 at 7:06













ok. I will look into assigning a different IP subnet to the wlan interface. but how to route that subnet to the rpi? newbie to the linux here :(
– AB pacino
Jan 13 at 7:11




ok. I will look into assigning a different IP subnet to the wlan interface. but how to route that subnet to the rpi? newbie to the linux here :(
– AB pacino
Jan 13 at 7:11












depends on what you're using for a router. if it's the rpi itself, you don't need to do anything else. otherwise just add a static route on your router for that IP subnet to the rpi's address. btw, you have PRETROUTING in your iptables command above...useful for fishing perhaps, but not routing :)
– cas
Jan 13 at 7:35





depends on what you're using for a router. if it's the rpi itself, you don't need to do anything else. otherwise just add a static route on your router for that IP subnet to the rpi's address. btw, you have PRETROUTING in your iptables command above...useful for fishing perhaps, but not routing :)
– cas
Jan 13 at 7:35













Google "transparent proxy".
– dirkt
Jan 13 at 9:28




Google "transparent proxy".
– dirkt
Jan 13 at 9:28












@cas Thanks for your reply. I am using rpi itself as the router. i added address=/#/192.168.1.2 in dnsmasq.conf for redirection and for most of the requests, it works except for facebook and youtube. I think that is because of SSL certificate. If that's the case, it shouldn't work for google.com too but it does. Any idea what could be done. ? and about iptables, is there any command which can meet my needs?
– AB pacino
Jan 14 at 5:01




@cas Thanks for your reply. I am using rpi itself as the router. i added address=/#/192.168.1.2 in dnsmasq.conf for redirection and for most of the requests, it works except for facebook and youtube. I think that is because of SSL certificate. If that's the case, it shouldn't work for google.com too but it does. Any idea what could be done. ? and about iptables, is there any command which can meet my needs?
– AB pacino
Jan 14 at 5:01















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f416755%2fredirect-all-devices-connected-to-ap-of-rpi-to-the-ip-address-of-rpi%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f416755%2fredirect-all-devices-connected-to-ap-of-rpi-to-the-ip-address-of-rpi%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay