Skip to main content
replaced http://superuser.com/ with https://superuser.com/
Source Link

Given: I have a machine (HostA) with only one NIC which has Internet connectivity. I have another machine (HostB) with one NIC on the same switch. HostB is not configured for Internet access yet. HostA has its default gateway and DNS servers appropriately configured. IPv4 is being used. OSes on the hosts are Ubuntu 13 and Fedora17.

What I want: Now, I would like HostB to have Internet connectivity, too. Is this possible using 'some' combination of iptables, virtual tun/tap devices, or a VPN setup between HostA and HostB, etc?

What I already know and can do: Currently, I can use an ssh-based SOCKS proxy on HostB (ssh -D 9050 UserA@HostA) and route traffic of select 'socksifiable' applications on HostB via this proxy to HostA and beyond. However, sadly, not all applications are socksifiable. Now, I know very well that if HostA had 2 NICs, I could have used some iptables rules to convert HostA into a gateway that would then route traffic between its NIC-1 and NIC-2 (where NIC-1 would be connected to HostB and NIC-2 to Internet). But installing another NIC in HostA is not feasible for me.

PS: I had posted this earlierposted this earlier on superuser.com but got no useful information.

edit 1:

network information

Host A:

:> ip addr [...] 2: p4p1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether d4:be:d9:d5:46:05 brd ff:ff:ff:ff:ff:ff inet 192.168.22.9/24 brd 192.168.22.255 scope global p4p1 :> ip route default via 192.168.22.254 dev p4p1 proto static 192.168.22.0/24 dev p4p1 proto kernel scope link src 192.168.22.9 

Host B:

:> ip addr [...] 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 30:f9:ed:d9:2e:20 brd ff:ff:ff:ff:ff:ff inet 192.168.22.234/24 brd 192.168.22.255 scope global eth0 :> ip route 169.254.0.0/16 dev eth0 scope link metric 1000 192.168.22.0/24 dev eth0 proto kernel scope link src 192.168.22.234 metric 1 

Given: I have a machine (HostA) with only one NIC which has Internet connectivity. I have another machine (HostB) with one NIC on the same switch. HostB is not configured for Internet access yet. HostA has its default gateway and DNS servers appropriately configured. IPv4 is being used. OSes on the hosts are Ubuntu 13 and Fedora17.

What I want: Now, I would like HostB to have Internet connectivity, too. Is this possible using 'some' combination of iptables, virtual tun/tap devices, or a VPN setup between HostA and HostB, etc?

What I already know and can do: Currently, I can use an ssh-based SOCKS proxy on HostB (ssh -D 9050 UserA@HostA) and route traffic of select 'socksifiable' applications on HostB via this proxy to HostA and beyond. However, sadly, not all applications are socksifiable. Now, I know very well that if HostA had 2 NICs, I could have used some iptables rules to convert HostA into a gateway that would then route traffic between its NIC-1 and NIC-2 (where NIC-1 would be connected to HostB and NIC-2 to Internet). But installing another NIC in HostA is not feasible for me.

PS: I had posted this earlier on superuser.com but got no useful information.

edit 1:

network information

Host A:

:> ip addr [...] 2: p4p1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether d4:be:d9:d5:46:05 brd ff:ff:ff:ff:ff:ff inet 192.168.22.9/24 brd 192.168.22.255 scope global p4p1 :> ip route default via 192.168.22.254 dev p4p1 proto static 192.168.22.0/24 dev p4p1 proto kernel scope link src 192.168.22.9 

Host B:

:> ip addr [...] 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 30:f9:ed:d9:2e:20 brd ff:ff:ff:ff:ff:ff inet 192.168.22.234/24 brd 192.168.22.255 scope global eth0 :> ip route 169.254.0.0/16 dev eth0 scope link metric 1000 192.168.22.0/24 dev eth0 proto kernel scope link src 192.168.22.234 metric 1 

Given: I have a machine (HostA) with only one NIC which has Internet connectivity. I have another machine (HostB) with one NIC on the same switch. HostB is not configured for Internet access yet. HostA has its default gateway and DNS servers appropriately configured. IPv4 is being used. OSes on the hosts are Ubuntu 13 and Fedora17.

What I want: Now, I would like HostB to have Internet connectivity, too. Is this possible using 'some' combination of iptables, virtual tun/tap devices, or a VPN setup between HostA and HostB, etc?

What I already know and can do: Currently, I can use an ssh-based SOCKS proxy on HostB (ssh -D 9050 UserA@HostA) and route traffic of select 'socksifiable' applications on HostB via this proxy to HostA and beyond. However, sadly, not all applications are socksifiable. Now, I know very well that if HostA had 2 NICs, I could have used some iptables rules to convert HostA into a gateway that would then route traffic between its NIC-1 and NIC-2 (where NIC-1 would be connected to HostB and NIC-2 to Internet). But installing another NIC in HostA is not feasible for me.

PS: I had posted this earlier on superuser.com but got no useful information.

edit 1:

network information

Host A:

:> ip addr [...] 2: p4p1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether d4:be:d9:d5:46:05 brd ff:ff:ff:ff:ff:ff inet 192.168.22.9/24 brd 192.168.22.255 scope global p4p1 :> ip route default via 192.168.22.254 dev p4p1 proto static 192.168.22.0/24 dev p4p1 proto kernel scope link src 192.168.22.9 

Host B:

:> ip addr [...] 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 30:f9:ed:d9:2e:20 brd ff:ff:ff:ff:ff:ff inet 192.168.22.234/24 brd 192.168.22.255 scope global eth0 :> ip route 169.254.0.0/16 dev eth0 scope link metric 1000 192.168.22.0/24 dev eth0 proto kernel scope link src 192.168.22.234 metric 1 
added info from chat; rephrased mistakable question
Source Link
Hauke Laging
  • 94.8k
  • 21
  • 132
  • 185

Given: I have an Internet-enableda machine, HostA, (HostA) with only one NIC which has Internet connectivity. I have another machine, HostB, (HostB) with one NIC thaton the same switch. HostB is not configured for Internet-enabled. HostA and HostB are both plugged into a switch access yet. HostA has its default gateway and DNS servers appropriately configured. IPv4 is being used. OSes on the hosts are Ubuntu 13 and Fedora17.

What I want: Now, I would like HostB to be able to share HostA'shave Internet-connection connectivity, too. Is this possible using 'some' combination of iptables, virtual tun/tap devices, or a VPN setup between HostA and HostB, etc?

What I already know and can do: Currently, I can use an ssh-based SOCKS proxy on HostB (ssh -D 9050 UserA@HostA) and route traffic of select 'socksifiable' applications on HostB via this proxy to HostA and beyond. However, sadly, not all applications are socksifiable. So, I would like to have the entire network traffic from/to HostB to go via HostA. Now, I know very well that if HostA had 2 NICs, I could have used some iptables rules to convert HostA into a gateway that would then route traffic between its NIC-1 and NIC-2 (where NIC-1 would be connected to HostB and NIC-2 to Internet). But installing another NIC in HostA is not feasible for me.

PS: I had posted this earlier on superuser.com but got no useful information.

edit 1:

network information

Host A:

:> ip addr [...] 2: p4p1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether d4:be:d9:d5:46:05 brd ff:ff:ff:ff:ff:ff inet 192.168.22.9/24 brd 192.168.22.255 scope global p4p1 :> ip route default via 192.168.22.254 dev p4p1 proto static 192.168.22.0/24 dev p4p1 proto kernel scope link src 192.168.22.9 

Host B:

:> ip addr [...] 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 30:f9:ed:d9:2e:20 brd ff:ff:ff:ff:ff:ff inet 192.168.22.234/24 brd 192.168.22.255 scope global eth0 :> ip route 169.254.0.0/16 dev eth0 scope link metric 1000 192.168.22.0/24 dev eth0 proto kernel scope link src 192.168.22.234 metric 1 

Given: I have an Internet-enabled machine, HostA, with only one NIC. I have another machine, HostB, with one NIC that is not Internet-enabled. HostA and HostB are both plugged into a switch. HostA has its default gateway and DNS servers appropriately configured. IPv4 is being used. OSes on the hosts are Ubuntu 13 and Fedora17.

What I want: Now, I would like HostB to be able to share HostA's Internet-connection. Is this possible using 'some' combination of iptables, virtual tun/tap devices, or a VPN setup between HostA and HostB, etc?

What I already know and can do: Currently, I can use an ssh-based SOCKS proxy on HostB (ssh -D 9050 UserA@HostA) and route traffic of select 'socksifiable' applications on HostB via this proxy to HostA and beyond. However, sadly, not all applications are socksifiable. So, I would like to have the entire network traffic from/to HostB to go via HostA. Now, I know very well that if HostA had 2 NICs, I could have used some iptables rules to convert HostA into a gateway that would then route traffic between its NIC-1 and NIC-2 (where NIC-1 would be connected to HostB and NIC-2 to Internet). But installing another NIC in HostA is not feasible for me.

PS: I had posted this earlier on superuser.com but got no useful information.

Given: I have a machine (HostA) with only one NIC which has Internet connectivity. I have another machine (HostB) with one NIC on the same switch. HostB is not configured for Internet access yet. HostA has its default gateway and DNS servers appropriately configured. IPv4 is being used. OSes on the hosts are Ubuntu 13 and Fedora17.

What I want: Now, I would like HostB to have Internet connectivity, too. Is this possible using 'some' combination of iptables, virtual tun/tap devices, or a VPN setup between HostA and HostB, etc?

What I already know and can do: Currently, I can use an ssh-based SOCKS proxy on HostB (ssh -D 9050 UserA@HostA) and route traffic of select 'socksifiable' applications on HostB via this proxy to HostA and beyond. However, sadly, not all applications are socksifiable. Now, I know very well that if HostA had 2 NICs, I could have used some iptables rules to convert HostA into a gateway that would then route traffic between its NIC-1 and NIC-2 (where NIC-1 would be connected to HostB and NIC-2 to Internet). But installing another NIC in HostA is not feasible for me.

PS: I had posted this earlier on superuser.com but got no useful information.

edit 1:

network information

Host A:

:> ip addr [...] 2: p4p1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether d4:be:d9:d5:46:05 brd ff:ff:ff:ff:ff:ff inet 192.168.22.9/24 brd 192.168.22.255 scope global p4p1 :> ip route default via 192.168.22.254 dev p4p1 proto static 192.168.22.0/24 dev p4p1 proto kernel scope link src 192.168.22.9 

Host B:

:> ip addr [...] 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 30:f9:ed:d9:2e:20 brd ff:ff:ff:ff:ff:ff inet 192.168.22.234/24 brd 192.168.22.255 scope global eth0 :> ip route 169.254.0.0/16 dev eth0 scope link metric 1000 192.168.22.0/24 dev eth0 proto kernel scope link src 192.168.22.234 metric 1 
Source Link
Harry
  • 834
  • 3
  • 11
  • 21

Can iptables be used to convert a single-homed host into a NAT server?

Given: I have an Internet-enabled machine, HostA, with only one NIC. I have another machine, HostB, with one NIC that is not Internet-enabled. HostA and HostB are both plugged into a switch. HostA has its default gateway and DNS servers appropriately configured. IPv4 is being used. OSes on the hosts are Ubuntu 13 and Fedora17.

What I want: Now, I would like HostB to be able to share HostA's Internet-connection. Is this possible using 'some' combination of iptables, virtual tun/tap devices, or a VPN setup between HostA and HostB, etc?

What I already know and can do: Currently, I can use an ssh-based SOCKS proxy on HostB (ssh -D 9050 UserA@HostA) and route traffic of select 'socksifiable' applications on HostB via this proxy to HostA and beyond. However, sadly, not all applications are socksifiable. So, I would like to have the entire network traffic from/to HostB to go via HostA. Now, I know very well that if HostA had 2 NICs, I could have used some iptables rules to convert HostA into a gateway that would then route traffic between its NIC-1 and NIC-2 (where NIC-1 would be connected to HostB and NIC-2 to Internet). But installing another NIC in HostA is not feasible for me.

PS: I had posted this earlier on superuser.com but got no useful information.