9 replies
by cpfeiffe
If you're asking how to share an Internet connection through your Linux machine to other Windows users on your network, you can use IPTables. Create a new file called rc.firewall in /etc/rc.d/ (or wherever you place your startup scripts) and add the following to it:
#!/bin/sh
# This sets the second NIC to the IP we want to use for the routing:
ifconfig eth1 192.168.0.1
# This line brings eth1 online:
ifconfig eth1 up
echo "1" > /proc/sys/net/ipv4/ip_forward
# Here we go:
echo "Starting IP Masquerading..."
iptables -A FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
iptables -A FORWARD -j LOG
echo "Enabling SNAT..."
iptables -t nat -A PREROUTING -p tcp --dport 3389 -i eth0 -j DNAT --to 192.168.0.2:3389
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo "Firewall Configured Successfully..."
# Don't forget to chmod +x rc.firewall before running it.
# And add the next line to /etc/rc.d/rc.local (or whatever startup directory/script you use):
# /etc/rc.d/rc.firewall
This is a basic firewall ruleset for IPTables. Read the manpage for iptables or do "iptables -h" for more information.
If you're asking how to share an Internet connection through your Linux machine to other Windows users on your network, you can use IPTables. Create a new file called rc.firewall in /etc/rc.d/ (or wherever you place your startup scripts) and add the following to it:
#!/bin/sh
# This sets the second NIC to the IP we want to use for the routing:
ifconfig eth1 192.168.0.1
# This line brings eth1 online:
ifconfig eth1 up
echo "1" > /proc/sys/net/ipv4/ip_forward
# Here we go:
echo "Starting IP Masquerading..."
iptables -A FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
iptables -A FORWARD -j LOG
echo "Enabling SNAT..."
iptables -t nat -A PREROUTING -p tcp --dport 3389 -i eth0 -j DNAT --to 192.168.0.2:3389
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo "Firewall Configured Successfully..."
# Don't forget to chmod +x rc.firewall before running it.
# And add the next line to /etc/rc.d/rc.local (or whatever startup directory/script you use):
# /etc/rc.d/rc.firewall
This is a basic firewall ruleset for IPTables. Read the manpage for iptables or do "iptables -h" for more information.
If you're asking how to share an Internet connection through your Linux machine to other Windows users on your network, you can use IPTables. Create a new file called rc.firewall in /etc/rc.d/ (or wherever you place your startup scripts) and add the following to it:
#!/bin/sh
# This sets the second NIC to the IP we want to use for the routing:
ifconfig eth1 192.168.0.1
# This line brings eth1 online:
ifconfig eth1 up
echo "1" > /proc/sys/net/ipv4/ip_forward
# Here we go:
echo "Starting IP Masquerading..."
iptables -A FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
iptables -A FORWARD -j LOG
echo "Enabling SNAT..."
iptables -t nat -A PREROUTING -p tcp --dport 3389 -i eth0 -j DNAT --to 192.168.0.2:3389
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo "Firewall Configured Successfully..."
# Don't forget to chmod +x rc.firewall before running it.
# And add the next line to /etc/rc.d/rc.local (or whatever startup directory/script you use):
# /etc/rc.d/rc.firewall
This is a basic firewall ruleset for IPTables. Read the manpage for iptables or do "iptables -h" for more information.
If you're asking how to share an Internet connection through your Linux machine to other Windows users on your network, you can use IPTables. Create a new file called rc.firewall in /etc/rc.d/ (or wherever you place your startup scripts) and add the following to it:
#!/bin/sh
# This sets the second NIC to the IP we want to use for the routing:
ifconfig eth1 192.168.0.1
# This line brings eth1 online:
ifconfig eth1 up
echo "1" > /proc/sys/net/ipv4/ip_forward
# Here we go:
echo "Starting IP Masquerading..."
iptables -A FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
iptables -A FORWARD -j LOG
echo "Enabling SNAT..."
iptables -t nat -A PREROUTING -p tcp --dport 3389 -i eth0 -j DNAT --to 192.168.0.2:3389
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo "Firewall Configured Successfully..."
# Don't forget to chmod +x rc.firewall before running it.
# And add the next line to /etc/rc.d/rc.local (or whatever startup directory/script you use):
# /etc/rc.d/rc.firewall
This is a basic firewall ruleset for IPTables. Read the manpage for iptables or do "iptables -h" for more information.
If you're asking how to share an Internet connection through your Linux machine to other Windows users on your network, you can use IPTables. Create a new file called rc.firewall in /etc/rc.d/ (or wherever you place your startup scripts) and add the following to it:
#!/bin/sh
# This sets the second NIC to the IP we want to use for the routing:
ifconfig eth1 192.168.0.1
# This line brings eth1 online:
ifconfig eth1 up
echo "1" > /proc/sys/net/ipv4/ip_forward
# Here we go:
echo "Starting IP Masquerading..."
iptables -A FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
iptables -A FORWARD -j LOG
echo "Enabling SNAT..."
iptables -t nat -A PREROUTING -p tcp --dport 3389 -i eth0 -j DNAT --to 192.168.0.2:3389
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo "Firewall Configured Successfully..."
# Don't forget to chmod +x rc.firewall before running it.
# And add the next line to /etc/rc.d/rc.local (or whatever startup directory/script you use):
# /etc/rc.d/rc.firewall
This is a basic firewall ruleset for IPTables. Read the manpage for iptables or do "iptables -h" for more information.
If you're asking how to share an Internet connection through your Linux machine to other Windows users on your network, you can use IPTables. Create a new file called rc.firewall in /etc/rc.d/ (or wherever you place your startup scripts) and add the following to it:
#!/bin/sh
# This sets the second NIC to the IP we want to use for the routing:
ifconfig eth1 192.168.0.1
# This line brings eth1 online:
ifconfig eth1 up
echo "1" > /proc/sys/net/ipv4/ip_forward
# Here we go:
echo "Starting IP Masquerading..."
iptables -A FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
iptables -A FORWARD -j LOG
echo "Enabling SNAT..."
iptables -t nat -A PREROUTING -p tcp --dport 3389 -i eth0 -j DNAT --to 192.168.0.2:3389
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo "Firewall Configured Successfully..."
# Don't forget to chmod +x rc.firewall before running it.
# And add the next line to /etc/rc.d/rc.local (or whatever startup directory/script you use):
# /etc/rc.d/rc.firewall
This is a basic firewall ruleset for IPTables. Read the manpage for iptables or do "iptables -h" for more information.
If you're asking how to share an Internet connection through your Linux machine to other Windows users on your network, you can use IPTables. Create a new file called rc.firewall in /etc/rc.d/ (or wherever you place your startup scripts) and add the following to it:
#!/bin/sh
# This sets the second NIC to the IP we want to use for the routing:
ifconfig eth1 192.168.0.1
# This line brings eth1 online:
ifconfig eth1 up
echo "1" > /proc/sys/net/ipv4/ip_forward
# Here we go:
echo "Starting IP Masquerading..."
iptables -A FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
iptables -A FORWARD -j LOG
echo "Enabling SNAT..."
iptables -t nat -A PREROUTING -p tcp --dport 3389 -i eth0 -j DNAT --to 192.168.0.2:3389
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo "Firewall Configured Successfully..."
# Don't forget to chmod +x rc.firewall before running it.
# And add the next line to /etc/rc.d/rc.local (or whatever startup directory/script you use):
# /etc/rc.d/rc.firewall
This is a basic firewall ruleset for IPTables. Read the manpage for iptables or do "iptables -h" for more information.
I have NO IDEA why that answer is listed 8 times.
(NOTE: SNAT is an example on how to do port forwarding. The example above uses the port for MS Terminal Server access.)
This discussion is closed to new replies.
Trending Linux posts
Sort by Trending