LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices



Reply
 
Search this Thread
Old 10-15-2007, 08:07 PM   #1
alpha_hack
Member
 
Registered: Jul 2007
Location: Sofia, Bulgaria
Distribution: Slackware 13.1x86_64
Posts: 75

Rep: Reputation: 15
Iptables in slackware


Hi there,

I'm facing a problem with iptables. I'm new in network configuration in linux and I want to set up two networks. I have a LAN at home and at School and I want to be able to change my networks when I'm at school/home. I'm told that it can be done with iptables but I'm not quite sure if it's possible ?

Particularly I want to do something like this:
Code:
eth0      Link encap:Ethernet  HWaddr 00:03:0D:0D:4D:32  
          inet addr:192.168.1.123  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr:*** Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:86527 errors:0 dropped:0 overruns:0 frame:0
          TX packets:90433 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:65037673 (62.0 MiB)  TX bytes:34605949 (33.0 MiB)
          Interrupt:17 

eth1      Link encap:Ethernet  HWaddr 00:03:0D:0D:4D:32  
          inet addr:192.168.0.123  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr:*** Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:86527 errors:0 dropped:0 overruns:0 frame:0
          TX packets:90433 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:65037673 (62.0 MiB)  TX bytes:34605949 (33.0 MiB)
          Interrupt:17 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:3919 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3919 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1845955 (1.7 MiB)  TX bytes:1845955 (1.7 MiB)

I hope you understood me..
If somebody could give me some information about how it can be done and what am I supposed to know to do it. I want to do some reading ( I don't expect someone just tell me the commands )



P.S. I'm sorry for the wrong forum category... Could someone please move my topic to Networking ? Thanks in advance!


Best wishes,
tftd

Last edited by alpha_hack; 10-16-2007 at 04:25 AM. Reason: Mistake in the example ifconfig
 
Old 10-15-2007, 10:29 PM   #2
aherrys
Member
 
Registered: Jul 2003
Posts: 64

Rep: Reputation: 15
Actually I am not sure what you are actually trying to do.

Iptables is used mainly for security reason, or if you want to build a router/firewall out of a linux machine. It can be configured with a specific rule, to drop, alter or pass the properties (like IP address, port etc.) of certain IP Packets based on certain criteria from or out of your machine.

And these are done mainly for security reason, for example like NAT (Network Address Translation) feature in a firewall.

If you want to change your machine IP address based on the location where you at, then may be iptables is not what you are looking for. I would think that you probably should be looking into dhcp or someway to manipulate your rc.inet1 while it is booting up.

Anyway here is some links that I found good on iptables:

http://www.linuxguruz.com/iptables/howto/ - A MUST read

http://www.justlinux.com/nhf/Securit...es_Basics.html
 
Old 10-15-2007, 11:47 PM   #3
davimint
Member
 
Registered: Jan 2006
Distribution: Slackware Current
Posts: 272

Rep: Reputation: 33
alpha hack
I'm trying to learn networking so when I looked at your example on eth1 I'm confused
as to it's output. You have a masked the last 8 bits of a number but it shows a broadcast of 192.168.1.255 and IP address of 192.168.0.123 so it would not be on the same network as I understand it.
Like I stated "I'm learning" so maybe I don't understand what your asking.
 
Old 10-16-2007, 03:07 AM   #4
alpha_hack
Member
 
Registered: Jul 2007
Location: Sofia, Bulgaria
Distribution: Slackware 13.1x86_64
Posts: 75

Original Poster
Rep: Reputation: 15
Hi there,

I'm actually tying to make 2 different networks and switch them.
Like on windows, you can create different networks, enable and disable them.

I am sure it's possible on linux but don't know how and what I'm exactly looking for... So sorry if I am asking stupid questions :P



Best wishes,
tftd
 
Old 10-16-2007, 03:19 AM   #5
Alien_Hominid
Senior Member
 
Registered: Oct 2005
Location: Lithuania
Distribution: Hybrid
Posts: 2,247

Rep: Reputation: 53
If you get your network address using DHCP protocol, then just rerun rc.inet1 each time. You can find it in /etc/rc.d

Last edited by Alien_Hominid; 10-16-2007 at 03:20 AM.
 
Old 10-16-2007, 03:55 AM   #6
alpha_hack
Member
 
Registered: Jul 2007
Location: Sofia, Bulgaria
Distribution: Slackware 13.1x86_64
Posts: 75

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Alien_Hominid View Post
If you get your network address using DHCP protocol, then just rerun rc.inet1 each time. You can find it in /etc/rc.d
I've saw that. Fortunately my school has DHCP. So, I'm currently online, but I was wondering if it's possible to have another network which I could "ifconfig ethX up" when I need it?
 
Old 10-16-2007, 04:35 AM   #7
Alien_Hominid
Senior Member
 
Registered: Oct 2005
Location: Lithuania
Distribution: Hybrid
Posts: 2,247

Rep: Reputation: 53
So you need to write a script which swaps rc.inet1.conf
 
Old 10-16-2007, 04:48 AM   #8
alpha_hack
Member
 
Registered: Jul 2007
Location: Sofia, Bulgaria
Distribution: Slackware 13.1x86_64
Posts: 75

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Alien_Hominid View Post
So you need to write a script which swaps rc.inet1.conf

Ok then, what documentation will I need to read to do that ?
 
Old 10-16-2007, 07:50 AM   #9
Alien_Hominid
Senior Member
 
Registered: Oct 2005
Location: Lithuania
Distribution: Hybrid
Posts: 2,247

Rep: Reputation: 53
Open rc.inet1.conf and all settings are explained there.

Basically, you need the scripts which do something similar to:

Code:
mv /etc/rc.d/rc.inet1.conf /etc/rc.d/rc.inet1.conf.school
exec /etc/rc.d/rc.inet1
and

Code:
mv /etc/rc.d/rc.inet1.conf /etc/rc.d/rc.inet1.home
exec /etc/rc.d/rc.inet1

Last edited by Alien_Hominid; 10-16-2007 at 07:53 AM.
 
Old 10-16-2007, 10:19 AM   #10
rworkman
Slackware Contributor
 
Registered: Oct 2004
Location: Tuscaloosa, Alabama (USA)
Distribution: Slackware
Posts: 1,973

Rep: Reputation: Disabled
Personally, I'd just serve dhcp in my home network too and be done with it. Problem solved.

Alternatively, you could create a short script to use ifconfig(8) and route(8) to manually configure your network. See /etc/rc.d/rc.inet1 for examples of how to use those two commands.
 
Old 10-17-2007, 05:40 PM   #11
alpha_hack
Member
 
Registered: Jul 2007
Location: Sofia, Bulgaria
Distribution: Slackware 13.1x86_64
Posts: 75

Original Poster
Rep: Reputation: 15
Ok,

Thanks a lot for the valuable information you gave me !


Best wishes,
tftd
 
Old 10-18-2007, 04:30 AM   #12
reikyv
Member
 
Registered: Oct 2007
Location: Malaysia
Distribution: Slackware
Posts: 80

Rep: Reputation: 15
Hi, I do have the same problem before. But I was using RHEL that time, and I need to travel to different places, e.g. home, office, client side. And I feel tired to edit the network configuration file everytime. So I wrote my own shellscript to help me do this job. And then everytime when I am at a different place I just select the proper option from there.

Anyway, you don't need to be a experienced shellscript guru to do that, if you have time, go to this site:
http://www.linuxcommand.org/writing_shell_scripts.php
 
  


Reply

Tags
configuration, eth0, eth1, iptables, network


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Slackware 8.1 & Iptables Help siadam Linux - Networking 26 03-19-2007 01:17 PM
iptables on slackware Chikne Slackware 17 12-11-2006 08:03 AM
iptables help! on slackware 10.2 Tony/osIRIs Linux - Newbie 3 03-01-2006 09:29 PM
iptables and slackware Fetch Linux - Security 5 04-12-2005 12:41 AM
slackware 10 & iptables atari303 Linux - Networking 8 11-07-2004 03:17 AM


All times are GMT -5. The time now is 11:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration